-
Notifications
You must be signed in to change notification settings - Fork 17
StrictMode causes crashing (due to issue with <Html> root, and others) #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ah! I feel silly for not noticing but there's a comment in the embedded So maybe it's just a matter of catching up! |
Confirmed that this issue happens with older versions of all of these packages (including react 18) when you wrap Canvas children with I suppose the inheritance of StrictMode across the Canvas boundary is now automatic in the latest versions https://r3f.docs.pmnd.rs/tutorials/v9-migration-guide#strictmode which is what surfaced the issue--but the issue is apparently not SPECIFIC to these new versions. It is just an issue with StrictMode in general. |
Seems like this effect is also a problem in StrictMode. Line 131 in fc70f26
The double-firing of the effect sets the Not sure if you want to separate all the StrictMode issues or batch them into one thread. But I'll just keep documenting what I find. Possible fix:
Adding |
With latest versions of react, three, r3f, a11y packages, I'm encountering an issue in my vite and next projects. In some conditions, it is app crashing.
Here is a reproduction.
https://codesandbox.io/p/sandbox/7rkzpf
You'll see, on load, an error in the console:
If you unmount and remount the
<A11y>
component, with the provided button, the app will crash:(This is a simplification of the way my apps are currently crashing.)
THIS IS NOT AN ISSUE OUTSIDE OF STRICT MODE. As far as I can tell, removing the strict wrapper from my repro removes the issue. But that is not an option for me in my projects.
I'm no wizard! But, to my naive eye, all of this seems to be related to increased strictness with root handling in react. It seems the
<Html>
component might need to:I forked and tried to fix. I was able to stop the crashing by naively implementing the above. E.g. creating
el
androot
together in the same state hook and using anisUnmounted
ref as a check before render calls. However, I don't understand this library and all of its many a11y concerns to be confident in my fix--and I think I broke behaviors. (Tab focus stopped working properly after remount.)When I replaced the component with the drei
<Html>
component in my fork, all seemed to work just fine.But again--I might have introduced issues too subtle for me to notice!
The text was updated successfully, but these errors were encountered: