After calling dispatch in onPress, how shall I know store is updated with new state value in functional component in react-native. I want to navigate to next screen after store state updates.
CodePudding user response:
there are several ways to achieve this, to answer directly the way you have asked you can do this.
Create a value in your reducer called isLoading and default it to null. In the component access the value. When the value becomes true you can put a loading screen up or an activity indicator and when the value becomes false you can activate your navigation.
One of the better options may be to navigate immediately and then fetch the data and put the loader on the next screen. Its usually better for screens to ask for the data they need within themselves as apposed to before navigation as when the app scales it will be hard to track where data comes from otherwise.