Home Education React Native AsyncStorage storing values other than strings

React Native AsyncStorage storing values other than strings

0
React Native AsyncStorage storing values other than strings

Despite the fact that you can just store strings, you can likewise stringify articles and clusters with JSON to store them, at that point parse them again subsequent to recovering them.

This will just work appropriately with plain Object-occasions or exhibits, however, Objects acquiring from any models may cause startling issues.

An example :

// Saves to storage as a JSON-string
AsyncStorage.setItem('key', JSON.stringify(false))

// Retrieves from storage as boolean
AsyncStorage.getItem('key', (value) => {
    JSON.parse(value) // boolean false
})