Search code examples
react-nativereduxreact-reduxreact-navigationredux-saga

When to use redux in React Native?


I'm trying to build an app, it has 3 Reducers

  1. AccountDetails it holds all kind of user's products
  2. GeneralData (eg. device's unique id, token, etc)
  3. shopping carts

Me and my coworker currently building a registration screen that has 6 screens (the ui/ux team request this)

  1. input username
  2. input password & confirm the password
  3. input DoB
  4. input Email
  5. screen to submit all the four data nb: we use react-navigation

so my coworker suggesting to use redux to handle this kind of data flow, I think it is kinda "overkill" to create another redux for register, why not passing the username data, password, DoB, and email to route.params and submit it to the last screen and we will have lot of Reducers to handle registration, recover password, recover username, and maybe other things.

but we both want to make this application scalable and easier to maintain, but i don't really know the proper way to do that


Solution

  • A lot of people take the approach of wanting to throw Redux at every situation. A lot of other people try to avoid Redux, using it only when absolutely necessary.

    You mentioned that you and your coworker both want to make the application scalable and easier to maintain. You can make an argument for doing it either of the two ways you are considering, so neither way is necessary wrong.

    However, the general consensus is that you should probably not put your form state in Redux. Redux has an FAQ page on this question here.