[React 18] Add slow mode #21
Merged
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.
This is an essential part that most comparisons and ports to other libraries tend to miss.
Of course, React is not the most efficient way to render a viz like this. You're better off with GL. But this particular example I'm adding has a neat aspect.
When the checkbox is ticked, each square is forced to spend 0.1ms blocking the thread. This simulates "death by a thousand cuts" where you have a large update that needs to run a bunch of user-written code. There's just no way you can "optimize it away". What's interesting is how the system handles a bunch of computational work distributed between a tree of components.
Compare the behavior with startTransition vs without it.
Demo link
Tick this checkbox:
The effect is pronounced after you increase the tree size with the slider on the left.