【问题标题】:What is the best way to store objects in React Native; redux-persist or localStorage在 React Native 中存储对象的最佳方式是什么? redux-persist 或 localStorage
【发布时间】:2022-01-07 06:47:06
【问题描述】:

我想在我的 react 原生应用中存储一些数据。 哪一个是最佳实践; redux-persistlocalStorage?

【问题讨论】:

  • 感谢您的快速回答,@slideshowp2。我在我的应用程序中使用 Redux,那么最好使用 redux-persist?

标签: reactjs redux redux-persist


【解决方案1】:

localStorageredux-persist 的存储引擎之一。见https://github.com/rt2zz/redux-persist#storage-engines。它们不是一回事,无法比较。 redux-persist 是除了存储引擎之外,Redux persist 自带了 react 集成,方便使用,总体来说已经够用了。

redux-persist 提供了一些状态协调器策略,可以帮助您轻松协调状态。

您可以使用黑名单和白名单功能决定应将哪个状态切片保存到存储引擎。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-25
    • 1970-01-01
    • 2022-12-12
    • 2014-06-29
    • 2021-04-02
    • 1970-01-01
    • 2020-08-25
    • 1970-01-01
    相关资源
    最近更新 更多