Update Drawer Navigation using Redux in React Native - react-native

How to update the Drawer Navigation in a react native app based on a boolean in redux store. For example: I want the items in the drawer navigation to change once the user logs in. Is there a way to implement this in react native using redux ( using state is fine too ).
Thanks in advance!

You will have to create two navigation drawer instances. One for not logged in and the other for when the user is logged in and then use accordingly.

Related

React Native Navigation Syntax

What is the difference between using navigation.navigate() and navigation.dispatch(CommonAction.navigate()) in React Native?
The docs explanation is:
The dispatch method lets us send a navigation action object which determines how the navigation state will be updated. All of the navigation functions like navigate use dispatch behind the scenes.
https://reactnavigation.org/docs/navigation-prop/#dispatch
AFAIK there is no real difference between using actions and navigate

Pass data from profile screen to custom navigation drawer

I am displaying profile pic and username in my app drawer. But drawer updating when I restart the app again. I am new to react native so I don't know how to refresh my drawer after changing profile pic in my profile screen. I searched about it and found it can be done by redux, but I am not getting any proper code to do that.
Have a try by saving the userData in the Redux and get the userData from the redux in the Drawer Component so whenever data changes it will be reflected the Component where it is being used.
check out the official docs for redux.
https://react-redux.js.org

React Navigation Event on Same screen

I am currently using "didFocus" event in React Navigation which works fine for most of my cases. I am having issue when the screen is same and this event doesn't trigger.
Is there an event in React Navigation that occurs when the user is on same screen upon navigation?
When a route rerenders (for example if the route params change) it would trigger componentDidRecieveProps

how to set initial route screens in stacknaviagtor React native?

If user already loggedin for app,the initial screen should be home screen with stack navigator. How is it possible?
in case you are using React Navigation in your app, there is a complete flow right here:
https://reactnavigation.org/docs/en/auth-flow.html
i think you have to change some part of it due to using redux. hope it helps :)

using states in a react-navigation without redux

as written in the react-navigation page:
Warning: in the next major version of React Navigation, to be released in Fall 2018, we will no longer provide any information about how to integrate with Redux and it may cease to work.
In the next version of react-navigation it could be hard to use redux with react-navigation.
My question is: what can I do to use states (and passing states between screens) in a react-navigation app without using redux?
For children of navigator
react-navigation gives you an withNavigation HOC, so you can easily wrap the component inside it to access the navigation state and navigate.
Why you integrate react navigation with redux?
For me, I want to be able to perform navigation actions from outside of my components(screens). Eg: Redux-saga. If we don't integrate, we can't navigate via redux-saga.
For a task like that we don't need to integrate react-navigation and redux. We just need to use NavigationService.