简体   繁体   中英

AsyncStorage.multiRemove Not working On logout. in react native

I am Trying To Clear My All AsyncStore Except "read1","read2". But When I press Logout And then Open App again. I dont get Login Screen. I direct Redirect to second screen. But I remove All Item Except Some. so I think I made some mistakes or multiRemove not working. please help.

here is How I use multiRemove

 onPress: () => {
                    AsyncStorage.multiRemove(
                      "id",
                      "doctor_id",
                      "created_time",
                      "is_profile_completed",
                      "otp",
                      "otp_valid_till",
                      "nature",
                      "login_as",
                      "user_name",
                      "read2"
                    );
                       BackHandler.exitApp();
                    
                  },

I added that read2 to check whether its clearing or not but its not clear.

AsyncStorage.getAllKeys()
        .then(keys => AsyncStorage.multiRemove(keys))
        .then(() =>  BackHandler.exitApp(); );

async storage work asynchronously so you should have to wait for the work to be done then exit the app. eventually you have to wait for promise to be resolved and add your work in to then block when asynchronously work has been done successfully

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