react-three-fiber
react-three-fiber copied to clipboard
Suspense causes attach to be called multiple times
When using the attach prop with a function, its attach function gets called multiple times without a detach when a suspended sibiling component resumes. This causes potentially too many objects to be created.
Sandbox: https://codesandbox.io/s/append-bug-xslv50?file=/src/index.tsx
I’m seeing a similar bug of objects being duplicated. I have not found what’s specific LT causing it. But I notice the error happens on iOS chrome and safari on first load but not on reload. Also desktop doesn’t have the problem. I’m not using suspense or attach, but it seems related.
@clementshimizu if you can make a reproduction on codesandbox or similar we can get a better comparison. Looking into the above issue for the moment.
Fix published in R3F 8.0.18. @clementshimizu, if you're still having issues, best to open an issue with a reproduction so we can take a closer look.
Had to revert #2268 in 8.0.24 due to race conditions between useLayoutEffect/useEffect and the reconciler.
Merged a fix into #2465, this can be expected to be released in the next v9 candidate.