Comments (3)
gradually render your results by calling setState() in React after each yieldOrContinue() call.
However, this needs to be done carefully, because React is able to batch state updates. If done blindly, yielding after each setState might produce more re-renders than needed (= worse performance ultimately).
from main-thread-scheduling.
Hey, good question. I've been asked this before. Maybe I should add a FAQ section and include this question.
You can't interrupt the React rendering. However, you can:
- use the new concurrent rendering features in React 18 β
useDeferredValue()
,startTransition()
, anduseTransition
that can render without blocking the UI. React has their own scheduler that has similarities with whatmain-thread-scheduling
is doing. - gradually render your results by calling
setState()
in React after eachyieldOrContinue()
call.
from main-thread-scheduling.
Ah, you are right. I've started writing an FAQ section with a more nuanced answer and information on the topic. Thanks!
from main-thread-scheduling.
Related Issues (14)
- Add more priorities HOT 4
- callback based API HOT 3
- Can't find the effect. HOT 3
- Error when building a project with Vite HOT 2
- Stand-alone JS file? HOT 4
- Any GC concerns when using async/await HOT 2
- Donβt crash SSR HOT 6
- Possible to manually cancel a scheduled function HOT 3
- Support for postTask scheduling? HOT 2
- Easier web workers HOT 8
- Compile errors in v6.0.0 HOT 2
- Comparisson with other frameworks HOT 6
- Can it be used in vue3 οΌ HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from main-thread-scheduling.