how to remove an item from AsyncStorage in react-native

后端 未结 7 2957
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 21:56

how to remove an item from AsyncStorage? right now I am trying this code

AsyncStorage.removeItem(\'userId\');

but this is not working for me.

7条回答
  •  [愿得一人]
    2021-02-19 22:26

    try this for react-native

    const deletCar = async () => {
            try {
                await AsyncStorage.removeItem('@storage_Key').then(() => {
                   
                    // props.navigation.navigate('same page name refresh ');   
                   /* setprevCar({ carNumner: '', carModel: '' }) return  empty obj if deleted. */
                })
    
    
            }
            catch (exception) {
                return false;
            }
    
        }
    

提交回复
热议问题