Is it required to put await ahead of setItem ? #845
Unanswered
kailashkumar210
asked this question in
Q&A
Replies: 1 comment
|
You do not need Example: AsyncStorage.setItem('@token', token)
navigate('Home')This will usually still save the data, but you're not waiting for completion and you won't catch write errors. Safer version: try {
await AsyncStorage.setItem('@token', token)
navigate('Home')
} catch (e) {
console.error('Failed to persist token', e)
}So the rule of thumb is:
I would recommend |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Is it required to put await whenever doing setItem something in AsyncStorage ?
what will be the impact if I do not write await, will it still save the data ?
All reactions