Losing AsyncStorage data when closing the application

I have an issue in my app at the first time I should choose an item (every item have different period so I countdown) & keep it until the countdown finish so when I logged out then login I don’t lose the data but whenever I close all app screens of my phone I lost the data then I should login & then choose an item again !:confused:

 const { itemType, setItemType } = useContext(GlobalContext)

const handleValueChange = (itemValue, itemIndex) => setTypeValue(itemValue)

const choosePlant = async () => {

    try {

      setItemType(typeValue)

      await AsyncStorage.setItem('itemType', itemType)
  
      navigation.navigate('x')


    } catch (err) {

       console.log(err)

}

Hi @keltouma, are you getting the item from the AsyncStorage back in your app? From the code snippet you shared, it doesn’t seem much clear to me. I’d suggest checking AsyncStorage documentation and see if everything is fine in terms of API methods.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.