-
-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Atoms always triggering suspense #1007
Comments
Hi, looks like you have a promise somewhere in atoms, right? If you could create a minimal reproduction in codesandbox, we might be able to see how it's going more closely. |
So, when you say a promise somewhere in the atoms, I don't think so. All of these literally replaced calls to useState and are just set and retrieved. I am using the helper
|
So, actually, I'm assuming this is because I'm using AtomwithStorage and that uses AsyncStorage on React Native. I can try to look at the source, I guess the question is, for these, is there any way to let the AsyncStorage happen in the background, so that it would literally only call the value from storage the very first time, when it doesn't have a value, and then it would maintain a non-async state, just writing / updating the AsyncStorage in the background without causing us to have to await a value that should be in local state? |
Possibly this is because the writeable part defaults to return type Promise. I don't yet understand what triggers it. React 18 is RC and they may release it very soon. I will probably choose to use the RC shortly so I can start using Suspense. Wonderful library! Thank you for Jotai! |
@crucialfelix |
but calling refetch still needs Suspense, right? |
Oh, yeah. You are right. So, the only solution would be |
Closing as answered. Please open a new discussion for further discussion. |
What is the |
|
Thank you @dai-shi - I feel like this should be more prominent on the tanstack/react-query page https://jotai.org/docs/integrations/query - it's so relevant here. We've been desperately trying to track down why our react app is suspending after loading... it's impossible to find out what is causing a suspend and finally tracked it to jotai... |
I missed the context. If it's about tanstack/query, you can use the second atom to avoid suspense. https://jotai.org/docs/integrations/query
If you have suggestions to improve the wording, would you please open a PR? |
I have an app that is not using any async atoms, however, suspense is required and is triggering in weird places.
Why would this be?
These are the atoms defined.
I can't use the app without suspense, and whenever I try to use the userAtom it trigger suspense, even though that is populated once and stays static throughout.
The text was updated successfully, but these errors were encountered: