Best way to store global data in AsyncStorage or redux?

自作多情 提交于 2019-12-10 11:57:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!