Async into var #890
Answered
by
ansh
Frostswing
asked this question in
Q&A
Async into var
#890
Replies: 3 comments 3 replies
-
anyone has a solution? |
Beta Was this translation helpful? Give feedback.
2 replies
-
No, you can use a useEffect and also make it happen. AsyncStorage, is, like the name says, async.
You want a sync solution. Jotai is the easiest one. You can also set it up using useEffect. The solution should be trivial so I won’t include the code here.
…On Thu, Dec 29 2022 at 21:47, Frostswing < ***@***.*** > wrote:
So to use AsyncStorage i need another library?
What is the main usage of this library then?
To be integrated inside usestates?
—
Reply to this email directly, view it on GitHub (
#890 (reply in thread)
) , or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AB6T25PGIGFOQLB2BVOX3N3WPW2RPANCNFSM6AAAAAATJSWKO4
).
You are receiving this because you commented. Message ID: <react-native-async-storage/async-storage/repo-discussions/890/comments/4551011
@ github. com>
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Frostswing
-
You can do that within a useEffect, just wait for the loading to finish below hiding the SplashScreen.
…On Thu, Dec 29 2022 at 23:27, Frostswing < ***@***.*** > wrote:
tbh i just wanted local storage for startup values, like chosen app
language ect...
I guess ill try this or the sync-storage library on the community.
Thank you!
—
Reply to this email directly, view it on GitHub (
#890 (reply in thread)
) , or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AB6T25N7FXDIBL42MLF2FZTWPXGH3ANCNFSM6AAAAAATJSWKO4
).
You are receiving this because you commented. Message ID: <react-native-async-storage/async-storage/repo-discussions/890/comments/4551475
@ github. com>
|
Beta Was this translation helpful? Give feedback.
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.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a very silly question, but for some reason i have found no answer to the past 3 days...
All i want to do is to put data from async storage and put it into a var...
For example my app could store the user's requestend language and reuse this data on the next app launch...
Using simple:
value= AsyncStorage.getItem('chosenLanguage')
wouldn't work since i get the promise instead of the data, this part i understand.
After a short check i saw that since its an async function i should use await like this:
var value=await AsyncStorage.getItem('@APP:chosenLanguage') ;
But then i get :
I tried using:
But it seems that while i can read collect and use it inside the getData function, i cannot use this data outside of the function...
Using a return to the avalue\collect variables gets me the promise instead of the data....
Can anyone help me please?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions