Replies: 1 comment
-
Valtio design is to optimize rerenders with objects. So, the best practice is to create nested objects. Something like: const elementsProxy = proxy<Record<string, {name: { value: string }; parentId: { value: string | null }}>>({}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'll start with an example:
This kind of example is cited in the docs as always being called whenever anything changes in the proxy. This means that if names change, the adjacency list is recalculated, which can be bad for performance.
One way we've worked around this in the past is to use
subscribe
like this:Is this just the natural way to work with valtio in a performance critical scenario? Are we missing a trick?
Beta Was this translation helpful? Give feedback.
All reactions