问题
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.
回答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.
来源:https://stackoverflow.com/questions/54806512/best-way-to-store-global-data-in-asyncstorage-or-redux