Replies: 1 comment 3 replies
-
not sure what you mean by restarting. react render is mostly just diffing, it looks for changes, it won't do a thing from scratch. you can cut down on this either with a state management tool (for instance zustand) or manually with React.memo. if things actually restart somewhere on render, then you have side effects, for instance a vector newly created inside the render function etc. components should be 100% resilient against render, they should not fall out or drop state, and you achieve that by avoiding all side effects. if you want to show me code (if it's small and readable) by all means we can look into it deeper. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want a component which uses RTF and
useFrame
to render a table with various items and the state dictates which item is in focus, but with smooth transitions, so when the state changes, the camera smoothly pans from one item to the next (according to the state change).I already achieved all of this, but I'm not sure what's the best design pattern. Since I don't want the RTF setup to restart on state change, I wrapped the
Canvas
insideReact.memo
and its prop is a reference to the state created withuseRef
. So theCanvas
only renders once, but is able to call the current state in each frame. Is this the most elegant way to solve this?Beta Was this translation helpful? Give feedback.
All reactions