You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because of the nature of the stacktrace (It does not show my code, there are too many internal function calls to have mine show up) it took me a really long time to figure out what was going on here, it was not obvious to me that AsyncStorage was producing this error.
Anyway, the following code solves it (just check instead of blindly set):
function set(key, value) {
value = JSON.stringify(value)
if (value) return AsyncStorage.setItem(key, value)
else console.log('not set, stringify failed:', key, value)
}
Thoughts:
check for unparsable values on setItem
improve error message to better reflect what the problem is so we can include the check (like in my example)
The text was updated successfully, but these errors were encountered:
If you're using flow, it should highlighted to you that AsyncStorage.setItem expects a non-null key and value. The error on the iOS side is expected as you can't have null entries in an array.
On Android it's not a problem, only on IOS. When you set a key `'string'` to value `undefined` it will succeed. with the following code:
But, if you then try to retrieve that item with the following code, the above error pops up.
Because of the nature of the stacktrace (It does not show my code, there are too many internal function calls to have mine show up) it took me a really long time to figure out what was going on here, it was not obvious to me that AsyncStorage was producing this error.
Anyway, the following code solves it (just check instead of blindly set):
Thoughts:
The text was updated successfully, but these errors were encountered: