[QUESTION] Why does a state change cause the render loop to fail even when the state isn't used by Canvas? #3547
Unanswered
varshithmee
asked this question in
Q&A
Replies: 1 comment
-
Are you sure the render loop itself is failing? This sounds like you are creating a stale closure somehow. Note that uniforms must be memoized or you may override them with an unreferenced object: const uniforms = useMemo(() => ({ uTime: { value: 0 } })
useFrame((state, delta) => {
uniforms.uTime.value += delta
})
<shaderMaterial uniforms={uniforms} /> |
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I followed the tutorial from this incredible blog and added my TypeScript tweaks to it.
It works perfectly on its own.
The issue starts when I add state to the other parts of the app. For example, using a simple useMouse hook in the parent component causes the render loop to fail if I move the mouse. Even Zustand state change causes the render loop to fail.
Below example shows zustand state changing when mouse hover the text.
20250521-1022-21.6067807.mp4
My immediate solution was to memoise the scene component, and it works, but I do not understand why it causes the render loop to fail in the first place.
Beta Was this translation helpful? Give feedback.
All reactions