I'm currently working on my first React Native app with react navigation after previously having a background in web react development.
In the past, I typically used useState for managing state. For instance, rendering a list of components based on data retrieved from a database query (such as a Friend List feature) or handling multi-step user sign up processes where each page contributes to the overall state that is then submitted via a post request.
However, it seems like this straightforward approach doesn't work quite the same in React Native. With React Navigation, every screen component is enclosed within a <Stack.Screen> component. How can I pass props to update parent component states? Is Redux necessary for achieving this?
To better explain how I managed this process in React before, let's look at an example involving a 5-step sign up flow:
The user lands on the signup page and fills out information on url/page1. After clicking next, the button triggers setState received from its parent to update the app.state. Then, it transitions to url/page2.
On url/page2, users input their address and continue by hitting next, updating the state and progressing to the subsequent step, and so forth.
Each page adds more details to the state until the final "submit" action aggregates all data and sends it through a POST request to the backend.
Within my React Native app.js, the structure looks similar but with different screens:
<NavigationContainer>
<Stack.Navigator initialRouteName = "TempHome">
<Stack.Screen name="TempHome" component={TempHome} />
...
</Stack.Navigator>
</NavigationContainer>
With each screen transitioning to the next using
const ProfileSetupF = () => navigation.navigate('ProfileSetupF')
How do I implement state props management within this context without consolidating all setup screens into a single component or stack.Screen? I want users to utilize the back button and experience smooth transitions when moving between screens. Some suggest utilizing Redux for this purpose. Any suggestions or guidance would be greatly appreciated.