英文:
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 .
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论