-
Hey! I want to share the quick (sketch) solution for small storage that depends on some props, other hooks (react-query in mind), and combinations of them (projections). The problems I want to solve:
codesandbox: https://codesandbox.io/s/intelligent-water-b0g7m?file=/src/App.tsx So, I just compare props (shallow) in useEffect and change only the changed ones (This is a common pattern for proxy based storage (mobx, valtio)) and provide proxy object to the provider. The implementation is a little too simple maybe and if you have ideas about this I appreciate the feedback. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
While valtio is fine to be used with React Context (and useConstant is good in this case), I don't see this makes use of the "mutation" style of valtio. If I were to do something like this, I'd use react-tracked, which probably would simplify things a lot. |
Beta Was this translation helpful? Give feedback.
While valtio is fine to be used with React Context (and useConstant is good in this case), I don't see this makes use of the "mutation" style of valtio. If I were to do something like this, I'd use react-tracked, which probably would simplify things a lot.