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
In this example setState should only be called once. This will freeze the application even though we don't use state as a dependency for the useEffect. We don't even need to use getItem within the effect for this to happen.
Environment
Async Storage version: 1.5.0
React-Native version: 0.59.9
Platform tested: iOS and Android
Logs/Error that are relevant:
The text was updated successfully, but these errors were encountered:
Like stated in the docs this was just an experiment with hook API and is not recommended to use.
You can see this issue for potential candidates for the hook, so you could implement in in your app. We're going to add a fully supported version in v2.
Current behavior
useAsyncStorage
always returns new functions, which can cause infinite loops if using eg.getItem
inside auseEffect
withgetItem
as a dependency.This is a huge issue if we use
useState
in conjunction with storage.Expected behavior
getItem, setItem
etc. should only update when they need to update.Repro steps
useAsyncStorage
,useState
anduseEffect
useEffect
and write to or read from async storage within the effect. AddgetItem
and/orsetItem
as dependency touseEffect
.Example
In this example
setState
should only be called once. This will freeze the application even though we don't usestate
as a dependency for theuseEffect
. We don't even need to usegetItem
within the effect for this to happen.Environment
The text was updated successfully, but these errors were encountered: