Replies: 1 comment 1 reply
-
If you use React DevTools, you can see the tracking information. Line 162 in cad437c You will find something wrong there, like it's unexpectedly deep props. Often the problem can happen with memoization or incorrect use of deps array. |
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
-
I have a fairly complex app with with multiple Valtio stores (each for their own concern).
The Valtio store is created inside a component inside a
useConstant()
(because I need to read some data fromlocalStorage
based on a localid
prop and then populate the store with it). The store is then passed down the component tree usingReact.Context
(as described on the wiki) and can be read using a helper:Suddenly, reading from a store through
useSnapshot
stopped working:As a workaround, I tried the following, which does seem to work:
So the data is changed correctly in the store, but reading the value using
useSnapshot()
does not trigger a rerender as I would expect. I do not useReact.memo()
.The issue only seems to occur if a second Valtio store (which works in a similar way) gets updated before the change in the FilterStore.
I tried reproducing it on Codesandbox, but I didn't succeed yet since the app is complex and I cannot share all code freely.
In the meanwhile, do you have any suggestions how I could debug
useSnapshot()
or can you think of other things I can try?Beta Was this translation helpful? Give feedback.
All reactions