Update project to work with latest react #443
Open
+3,783
−2,942
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This removes the usage of the legacy context apis which have been completely removed in react 19.
Additionally, it fixes: #408. It's not a great fix as it removes code deliberately added to help chrome GC unused webglcontexts, but chrome will GC them (eventually).. this is an api that is only supposed to be used for testing. The bug is caused because react (in dev mode) double renders to ensure your app is compatible with concurrent mode features, and destroying the webglcontext like this means on the second render the webglcontext is unusable. I've found no way to restore it
Finally it fixes an issue with nested
Node
s also caused by the double render. When a parent Node is unmounted it tells the children it is no longer a dependent but it doesn't remove the child node from itself as a dependency. When the tree is reconstructed in the second render it doesn't re-add the child as a dependency (because it was never removed on unmount) but this no-op means it doesn't add itself as a dependent again (which does need to happen because it was removed)Test plan
I've tested the example in the readme, and more complicated examples that have nested
Node
s.. The PR should be pretty safe because things can't get much more broken then they are now (with the latest react at least)