jjzjj

asyncstorage

全部标签

java - 我可以从 java 层访问存储在 React Native 的 AsyncStorage 中的数据吗?

我使用AsyncStorage在ReactNative中存储了一些用户首选项。现在,我需要从后台服务中获取这些偏好。我无法从Java层访问AsyncStorage。有办法吗?在iOS中,我们可以导入RCTAsyncLocalStorage.h并调用_getValueForKey。但是,我找不到在Android中执行此操作的方法。 最佳答案 我有以下代码可以完成这项工作。importcom.facebook.react.modules.storage.AsyncLocalStorageUtil;importcom.facebook.r

android - 如何在 React Native 中存储/保存数据

如何在reactnative中存储/保存数据。就像我们在android中使用shared-preference,reactnative有什么解决方案吗?我是新手react活跃。pleaseaddsampleexample 最佳答案 您可以使用ReactNativeAsyncStorage用于将数据存储到设备的本地存储。importAsyncStoragefrom'@react-native-async-storage/async-storage';用这个来保存数据AsyncStorage.setItem('key','value')

ios - 在 iOS 模拟器中刷新 React Native 应用程序是否等同于关闭应用程序并重新打开它?

我问这个是因为按cmd+r会导致所有组件都设置为默认状态。要使用从应用商店下载的应用来复制这一点,是否需要通过双击主页按钮强制关闭应用,向上滑动应用,然后重新打开它?我的商店中还没有任何应用程序,所以我无法对此进行测试。将相关数据保存在AsyncStorage中是否是在重新加载后保留状态的好方法?例如:我有一个登录用户,其信息被保存到状态。如果我刷新应用程序,该用户将丢失并被迫重新登录。但是,如果我将用户的信息保存到AsyncStorage并且我可以使用componentDidMount将它们恢复到状态>. 最佳答案 Isrefre

javascript - react native : TextInput with state and AsyncStorage

在键盘上打字时,我看到一些关于输入在JS代码之前的警告。NativeTextInput(reactnativeisawesome)is4eventsaheadofJS-trytomakeyourJSfaster.因此添加了debounce并让它“工作”:...import{debounce}from'lodash'...exportdefaultclassAppextendsReact.Component{constructor(props){super(props)this.state={data,indexRef:data.reduce((result,item,index)=>{

javascript - react native : TextInput with state and AsyncStorage

在键盘上打字时,我看到一些关于输入在JS代码之前的警告。NativeTextInput(reactnativeisawesome)is4eventsaheadofJS-trytomakeyourJSfaster.因此添加了debounce并让它“工作”:...import{debounce}from'lodash'...exportdefaultclassAppextendsReact.Component{constructor(props){super(props)this.state={data,indexRef:data.reduce((result,item,index)=>{

ios - 从 ios native 代码访问存储在 AsyncStorage 中的数据( objective-c )

我需要从iOS原生ObjectiveC代码访问存储在AsyncStorage中的数据。这是同步数据所必需的,而不是将App事件发送到JS,然后将其发送回native代码。 最佳答案 我刚遇到同样的问题。我的解决方案是将代码移至native端。在iOS上:#import#importRCTResponseSenderBlockcompletion=^(NSArray*response){NSString*theme=response[1][0][0][1];//SetupRCTRootViewwithinitialProperties

ios - 从 ios native 代码访问存储在 AsyncStorage 中的数据( objective-c )

我需要从iOS原生ObjectiveC代码访问存储在AsyncStorage中的数据。这是同步数据所必需的,而不是将App事件发送到JS,然后将其发送回native代码。 最佳答案 我刚遇到同样的问题。我的解决方案是将代码移至native端。在iOS上:#import#importRCTResponseSenderBlockcompletion=^(NSArray*response){NSString*theme=response[1][0][0][1];//SetupRCTRootViewwithinitialProperties

ios - React Native AsyncStorage 存储字符串以外的值

有没有办法用AsyncStorage存储字符串以外的值?例如,我想存储简单的bool值。AsyncStorage.setItem('key','ok');没问题,但是:AsyncStorage.setItem('key',false);不起作用.. 最佳答案 基于AsyncStorageReact-nativedocs,恐怕你只能存储字符串..staticsetItem(key:string,value:string,callback?:?(error:?Error)>=>void)Setsvalueforkeyandcallsca

ios - React Native AsyncStorage 存储字符串以外的值

有没有办法用AsyncStorage存储字符串以外的值?例如,我想存储简单的bool值。AsyncStorage.setItem('key','ok');没问题,但是:AsyncStorage.setItem('key',false);不起作用.. 最佳答案 基于AsyncStorageReact-nativedocs,恐怕你只能存储字符串..staticsetItem(key:string,value:string,callback?:?(error:?Error)>=>void)Setsvalueforkeyandcallsca

sqlite - 在带有 Redux 的 React Native 应用程序中使用 Realm

我即将着手开发ReactNative应用程序,并且完全相信使用Redux管理应用程序状态的好处,但是我想通过使用Realm进行持久存储,使应用程序的数据在离线时可用。我想知道Redux将如何与Realm一起玩?我正在开发的应用程序将通过RESTfulAPI提取大量JSON数据,然后我想将这些数据保存到本地存储-Realm似乎是一个很好的选择。然而,我不确定的是Realm数据库将如何存在于Redux存储中?它必须存在于商店外部吗?在基于Redux的应用程序中使用Realm是否有点自相矛盾?我很好地搜索了描述使用Realm或其他存储选项(Asyncstorage或SQLite)使用Redu