Best way to store global data in AsyncStorage or redux?

I am developing a feature like a cart of which data I want to use in multiple screens. Also, want to manage the view cart and clear cart items but locally only. What is the recommended way to go with?

1) AsyncStorage
2) Redux

Kindly help me and let me know if there is a misconception on my side.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

AsyncStorage and Redux serve different purposes.

AsyncStorage is there to allow you to store data that is persisted between app instances (that is, between restarts of your app).

Redux is a state management system that is meant to solve the problem of moving state around components in react.

What you’re describing can actually use both, where Redux is used for state management, and the redux store itself can be saved into AsyncStorage for later use. There are Redux related libraries that do just that, such as Redux-Persist.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x