React Native在所有其他页面之间共享数组,并实现添加和删除功能。

huangapple go评论70阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年1月6日 21:02:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/59612622.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定