简体   繁体   中英

Trying AsyncStorage on React Native

Currently, I am trying to storage a input value. However, it does not work. The code is able to launch without any error but the input values doesn't store to setTubeIT after I refresh the application.

                  <View style={styles.input}>
                    <TextInput placeholder="Inlet Temperature"
                        style={{flex:1}}
                        onChangeText={(value)=>setTubeIT(value)}
                        keyboardType={inputType}/>
                    <Text style={{marginLeft:10}}>°C</Text>

_storedata :async () => {
        try {
            await AsyncStorage.setItem(
                'Inlet Temperature', 'setShellIT'
            );
        } catch (error) {
    
        }
    
    },
    
    _retrievedData : async () => {
        try {
            const value = await AsyncStorage.getItem(
                'setShellIT');
                if (value!==null) {
                    console.log(value);
             }
    } catch (error) {

    }
}

Please console.log(error) in your catch block and see if it returns an error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM