atomWithStorage not working in ReactNative #2421
Unanswered
ahdam
asked this question in
Bug report
Replies: 2 comments 10 replies
-
I found the solution. |
Beta Was this translation helpful? Give feedback.
9 replies
-
How to add types here? thanks |
Beta Was this translation helpful? Give feedback.
1 reply
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm facing issues with atomWithStorage on ReactNative.
Current screen setup:
StackScreen1 - no children
StackScreen2 - has a TabNavigator with 3 tabs
TabScreen1
TabScreen2
TabScreen4
I want to save the last accessed tab in AsyncStorage.
The code below works when navigating from StackScreen2 to StackScreen1 and back to StackScreen2. In this case, the value is stored correctly in the atom, and I can read it fine, and set it to the initialRouteName param of the TabNavigator
The problem is every time I refresh the app, the value from the atom is gone (by this I mean it reverts to the default one: {value: "Tab 1"}).
Has anyone encountered this before?
This is my setup:
Beta Was this translation helpful? Give feedback.
All reactions