What is the better to manage state in React Native project on Expo?

Viewed 2329

I am creating React Native App for mobile on Expo. When we try to make mobile Apps, we should usually manage state in this app. However, I am using Expo. Of course, Expo is useful to start React Native App easily and quickly but sometimes Expo cannot accept modules.

So, in this case, I tried to use Realm to manage state but Expo can't follow this.

Could you teach me which way for state management is better in React Native on Expo?

2 Answers

There's a few ways to go about this, two of which I know and have used:

AsyncStorage: This is default with react-native and you won't need to install anything to use it, here's a few tutorials and documentation on it.

  1. https://facebook.github.io/react-native/docs/asyncstorage
  2. https://medium.com/building-with-react-native/what-is-asyncstorage-in-react-native-and-how-you-to-use-it-with-app-state-manager-1x09-b8c636ce5f6e
  3. https://medium.com/@richardzhanguw/storing-and-retrieving-objects-using-asyncstorage-in-react-native-6bb1745fdcdd

React-Redux: This is something I use a lot more, it utilises AsyncStorage but allows you to create a better storage flow and a system of persisting data so when you close the app and reopen it, the data will still be there. I've found React-Redux to be a lot easier once properly learned, here's a few documentations on it.

  1. http://www.reactnativeexpress.com/redux
  2. https://alligator.io/react/react-native-redux/
  3. https://medium.com/@relferreira/react-native-redux-react-navigation-ecec4014d648

A quick google search on either (react native using react redux or react native using async storage) will give you quite a few documentations/tutorials that is quite useful and you always have Stackoverflow, if you're ever stuck.

Related