英文:
React native share array with Add remove to all other pages
问题
如何在全局存储React Native数组,并在任何地方插入、删除和显示数据?(类似购物车)
英文:
how to store React native array globally and insert, delete and display data from anywhere? (Like shopping cart)
答案1
得分: 0
- 最简单的方法是使用AsyncStorage来存储你的数组。React Native Async Storage 现在是一个独立的包,你需要安装并链接它。
- 如果你在使用redux,使用redux-persist 来存储你的数组可能更合理,以避免干扰你的应用逻辑。
英文:
- The easiest way would be to use AsyncStorage to store your array.
React Native Async Storage is now a standalone package that you will have to install and link. - If you are using redux, it may make more sense to use redux-persist to store your array and not mess up your app logic.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论