sharing useFrame computed state across multiple components #1112
-
how does one share state computed within useFrame across multiple components? ie is a CustomEvent and handler preferred for propagating state? or a custom hook? ... i've tried a CustomEvent but this seems unwieldy and a custom hook more appropriate, tho when i try a custom hook i believe i have a conflict in state ... here's my custom hook ...
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
If you want to share a calculation then it should come from the state model or a parent. Look into zustand for instance. That space game on the gh front did that, a store that's doing frame by frame calculations and nested components can listen to it without being re-rendered. |
Beta Was this translation helpful? Give feedback.
-
found an appropriate answer here ... https://github.com/pmndrs/react-three-fiber/blob/master/markdown/pitfalls.md |
Beta Was this translation helpful? Give feedback.
If you want to share a calculation then it should come from the state model or a parent. Look into zustand for instance. That space game on the gh front did that, a store that's doing frame by frame calculations and nested components can listen to it without being re-rendered.