反应原生异步存储

时间:2021-04-16 09:08:57

标签: react-native sharedpreferences react-native-android

import AsyncStorage from '@react-native-async-storage/async-storage';

我正在使用上面的包。 2小时前它工作正常。但突然停止工作。没有问题或警告。

我在我的应用中使用 Aysncstorge 来保存一个值。它工作正常。她是我的代码。

  const Authorize = dispatch => async () =>{
        console.log("calledddd")
            try{
              let islogin = await  AsyncStorage.getItem('islogin')
               console.log(islogin)
            }catch(error){
                console.log(error)
            }
       console.log("called last")
    }

我也这样试过。

 AsyncStorage.getItem('islogin').then((islogin) => {
     console.log(islogin)
}).catch((error) => {
     console.log(error)
 })

1 个答案:

答案 0 :(得分:2)

从以下包中使用它:

<块引用>

@react-native-community/async-storage

享受!!!