It is possible to create derivations that can accept parameters #719
-
I'm trying to optimise the render of a big list, when selecting one of the items i'm adding the selected id to my store and for each item I'm comparing the current selected id with each item id to add some class, the problem is that because on each item i have the selected id, when this changes, all items get rerendered, I was trying to create a fn to pass the id of the item and using a derive i was returning true or false, which should only rerender the two items that changed:
the problem with above snippet is that when using it on a useSnapshot, i get react infinite re-renders. how can this kind of optimisations can be achieved in valtio? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
Thanks for your response, I ended up using useMemo:
this avoids infinite re-renders