The onLoad callback fires every render if the callback isn't memoized, because useEffect hook depends on the function instead of the mapped texture data. On the other hand, if the callback is memoized, it will only fire once and then never again, even if the data finishes loading later.
three
version: 0.164.1@react-three/fiber
version: 8.16.6@react-three/drei
version: 9.105.6node
version: v22.2.0npm
(oryarn
) version: 1.22.22Problem description:
The
onLoad
callback fires every render if the callback isn't memoized, becauseuseEffect
hook depends on the function instead of the mapped texture data. On the other hand, if the callback is memoized, it will only fire once and then never again, even if the data finishes loading later.Relevant code:
Caused by this code in
useTexture
:Suggested solution:
I will provide a PR with this change.