Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ignite Base Change
npm run test
)npm run lint
)Typically a Menu Drawer can be responsible for navigating to screens when deep into the navigation stack from the "Home Screen." Here we've set up a lean component that's business logic is handled at the highest level (
Root
) that is on par with the navigator - where it should be IMO. This allows the Drawer Content Component to be a "dumb" stand-alone component that functions without any knowledge of state,navigator
, anddispatch
.Since we wrap the
Navigator
with aDrawer
This upgrade method eliminates the pesky issue of passing around
navigator
anddispatch
to the Menu Drawer, which are necessary when dealing with navigation, as well as consequential async problems that arise fromnavigator
handling during the component and app lifecycle.YAY!!
How's it work?
DrawerContent
DrawerContent
component that will live in theDrawer
atRoot
DrawerContent
's parent is aScrollView
to allow for many items (buttons, etc.)DrawerButton
that has settabletext
and anonPress
functionDrawerContent
render
method with as manyDrawerButton
s as you like - even throw in your favorite logo 😉onPress
s' called function inside aconstructor
method, because binding inside theonPress
property creates a new function in therender
method, which causes react to reset that property - performing “work” where none is needed. (Thanks @skellock !)DrawerComponent
is passed a requiredonPushRoute
property fromRoot
DrawerContent
this function, we've allowed fornavigator
anddispatch
to remain inRoot
and still be accessed by ourDrawerContent
componentRoot
DrawerContent
component'sonPushRoute
property callshandlePushRoute
(which is also bound in aconstructor
method inRoot
handlePushRoute
pushes the route AND closes our Menu DrawerBing, Bang,