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
Related
My drawer items like login user name doesn't get refreshed when presses logout...but when i save my code in visual studio code then app rebuilt and it shows drawer items updated...I want to do it when a user press button in drawer items the whole app should reload automatically.I make react native app using expo.
tried react-native-restart
Basically, when your program performs login or logout, you should update the login/logout text and call setState() in your drawer component to re-render it. In case your drawer is using FlatList, or some PureComponent, you can only re-render it via update props.
For more details, you should provide more code so we can take a look.
I am using react native navigation v2 by wix. I have a welcome screen with login screen and register. I start the startAuth.js from App.js. There are two tabs with login and register.
But as soon as app starts the componentWillMount methods runs in the register screen but yet i am at login tab.
Why is this happening?
react-native-navigation's Tab does not support lazy loading. But there are two special lifecyle functions where you can put your logic when component appear or disappear on screen
componentDidAppear(): called each time this component appears on screen
componentDidDisappear(): called each time this component disappears from screen
https://wix.github.io/react-native-navigation/docs/screen-lifecycle
There is also a discussion about topic https://github.com/wix/react-native-navigation/issues/1250
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 :)
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.
I don't know if I am the one getting it wrong. I am working on a project, I use react navigation, and I am using drawer and stack navigator. But when I click on any menu on the drawer 1. The drawer will remain open until the next page appear 2. The menu that I click will remain active until the next screen appear.
I try to check other application performance, they don't perform like that. Is that how react navigation works or am I the one getting it wrong?
Please help because I am new to react native and react navigation.
i came across a post on Fixing common performance problems in React Navigation
i just change the code in componentdidmount method like this
componentDidMount(){
InteractionManager.runAfterInteractions(() => {
// Component is done animating
// Start making any request
});
};
with that my problem is solved but i dont know if is the right way of doing it.