Can I bind only relevant data to a component? #127
-
Hi, I am looking for a better way to work with nested data and proxies seems to be a good fit. I was wondering if I can bind nested data to a component and stop them to re-render if nothing changed. E.g. in below example all components get updated when I press a button. Can I stop this ? https://codesandbox.io/s/wandering-monad-15t9n?file=/src/App.js:375-448 THX! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
First things first, you need to use the snapshot. Dealing with the array is kind of hard. Best is:
For example: https://codesandbox.io/s/angry-bouman-belio?file=/src/App.js |
Beta Was this translation helpful? Give feedback.
-
I don't see the difference in the demo between using React.memo or not |
Beta Was this translation helpful? Give feedback.
-
We should have a cookbook section pointing to these best practices |
Beta Was this translation helpful? Give feedback.
First things first, you need to use the snapshot.
const snap = useSnapshot(store)
Dealing with the array is kind of hard. Best is:
For example: https://codesandbox.io/s/angry-bouman-belio?file=/src/App.js