RuleSource Checked
Keep per-frame values out of React state
Use refs and the render loop for values that change every frame.
Ready to use
Rule text
In React Three Fiber, do not call React state setters for per-frame transforms or other rapidly changing values. Mutate object refs inside useFrame and reserve React state for application state that should cause a render.Why it helps
The reasoning behind the entry
Rendering the React tree for frame-level values creates unnecessary work and can make motion feel uneven.
Filed under
Use it in more than one place
- Ecosystem
- React Three FiberThree.js
- Platform
- Web