React Native AsyncStorage storing values other than strings

前端 未结 6 1614
花落未央
花落未央 2021-01-03 17:46

Is there any way to store values other than strings with AsyncStorage? I want to store simple boolean values for example.

AsyncStorage.setItem(\'key\', \'ok\         


        
6条回答
  •  南方客
    南方客 (楼主)
    2021-01-03 18:11

    I have set value in "name" key in AsyncStorage

    AsyncStorage.setItem("name", "Hello");
    

    To get value from key "name"

    AsyncStorage.getItem("name").then((value) => {
       console.log("Get Value >> ", value);
    }).done();
    

    Output will be as follows:

    'Get Values >> ', 'Hello'
    

提交回复
热议问题