在React Native中是否有与localStorage等效的功能?

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

Is there an equivalent to localStorage in React Native?

问题

我想在我的React Native应用中实现与javascript localStorage等效的功能。但我不确定如何设置。为了使其按照我的期望方式工作,我希望localStorage每次应用打开时都能存储。有没有办法做到这一点?

英文:

I'd like to implement the equivalent to the javascript localStorage in my React Native app. But I'm unsure how to set. To function how I want it to, I would like the localStorage to be stored every time the app opens. Is there a way to do this?

答案1

得分: 1

Async Storage - https://github.com/react-native-async-storage/async-storage

Secure Storage (Expo) - https://docs.expo.dev/versions/latest/sdk/securestore/

英文:

Async Storage - https://github.com/react-native-async-storage/async-storage

Secure Storage (Expo) - https://docs.expo.dev/versions/latest/sdk/securestore/

答案2

得分: 0

比React Native Async Storage 更好的选择是React Native MMKV。它支持同步获取/设置字符串、布尔值和数字。更多关于为什么推荐使用MMKV而不是Async Storage的信息,请阅读这里

英文:

A better option than React Native Async Storage these days is React Native MMKV. It includes support for synchronously getting/setting strings, booleans and numbers.

Read more about why MMKV is recommended over Async Storage here.

答案3

得分: 0

在React Native应用程序中,可以使用AsyncStorage来本地持久化数据。您可以在此处查看。

英文:

In React Native applications, data can be persisted locally using AsyncStorage .

You can check it out here.

huangapple
  • 本文由 发表于 2023年5月25日 03:20:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76326785.html
匿名

发表评论

匿名网友

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

确定