useRecoilCallback batched set calls update state incorrectly
See original GitHub issueWe’ve been using Recoil quite extensively and believe we have encountered a bug with useRecoilCallback
and state updating.
There is a rootState
atom that we want to update via a useRecoilCallback
that contains multiple set
calls.
If the set
calls within useRecoilCallback
try to set the recoil state of rootState
directly or through a single selector layer, the final rootState
is as expected.
However, if there is more than one layer of selector dependencies, it is only the last set
that has a result on rootState
.
Here is the CodeSandbox.
Expected: All steps change their state from ['1', '2', '3']
to ['one', 'two', 'three']
Result: The only step changing the state is the last one for which set
has run. In effect: ['1', '2', '3']
changes to ['1', '2', 'three']
Issue Analytics
- State:
- Created a year ago
- Comments:13 (5 by maintainers)
Top GitHub Comments
@luishdz1010 - I see the issue, though it does seem like a different one than the OP.
Сould I work on this problem?