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
I get this error message when I try to set values with useSetRecoilState, before I use the useRecoilValue/useRecoilState.
The selector behind useSetRecoilState is setting value on atom that has async default value.
When I call the useRecoilValue(itemsInCartStore); somewhere before setting its values, I don't get any more this error.
I think that when the atom is called, the Suspence above it does first wait for it to get its value and then the setter has no problems, but when this is not the case the setter just try to set value on the atom before it is initialized. It makes of course sense, but is there any better way for such use-case? My goal is to synchronise in background the values of all the atoms before the user even need to use them.
My Code:
I have async LocalForage where I get all the default values like this:
I have main atom where to load the local storage data
The idea is to get all items from the indexed DB at once, and not make request by each atom separately. (even if request to local indexed DB is quite cheap and fast, still....)
In background of all user actions I synchronize the server with the local state of the user. I use similar selector:
As soon I try to get or set this atom in my setter, the error comes
drarmstr
changed the title
Error: Tried to set the value of Recoil selector itemsInCart__withFallback using an updater function, but it is an async selector in a pending or error state; this is not supported.
Cannot get values of other pending selectors while setting a selector.
Dec 4, 2020
This is related to #439 and #762. Selector set()'s are currently synchronous and can't handle getting other atoms in a pending or error state. Async selector sets may help solve this.
I get this error message when I try to set values with useSetRecoilState, before I use the useRecoilValue/useRecoilState.
The selector behind useSetRecoilState is setting value on atom that has async default value.
When I call the useRecoilValue(itemsInCartStore); somewhere before setting its values, I don't get any more this error.
I think that when the atom is called, the Suspence above it does first wait for it to get its value and then the setter has no problems, but when this is not the case the setter just try to set value on the atom before it is initialized. It makes of course sense, but is there any better way for such use-case? My goal is to synchronise in background the values of all the atoms before the user even need to use them.
My Code:
I have async LocalForage where I get all the default values like this:
I have main atom where to load the local storage data
Each atom store get its own default value then from the main init atom:
The idea is to get all items from the indexed DB at once, and not make request by each atom separately. (even if request to local indexed DB is quite cheap and fast, still....)
In background of all user actions I synchronize the server with the local state of the user. I use similar selector:
As soon I try to get or set this atom in my setter, the error comes
The text was updated successfully, but these errors were encountered: