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
Under what circumstances, unstable_shouldYield will return true? #14796
Comments
We yield to the host environment periodically – every 16ms or so – to allow the browse to process incoming events including user input. In the ideal case, we can finish all of the rendering in these small 16ms slices. However, if there are many other things happening at the same time, React work may "starve" and not be able to fully render in the small slices. So we have a second check: every pending render or state update has an "expiration time" (usually somewhere from 100ms to 5000ms) – if that time passes without the render finishing, we switch to a synchronous mode until that update can be finished. This is not ideal but it ensures that all updates get processed without waiting too long. We set a timer in the browser (e.g., with setTimeout) for that same expiration time. If that timer fires, we know we need to perform the work synchronously. If this happens, In the future, we plan to use a new |
Thanks for reply
|
|
Thank you very much.It's really nice of you! |
In Scheduler.js,
unstable_shouldYield() return true when currentDidTimeout is false and shouldYieldToHost() return true, but why?
shouldYieldToHost() return true means there's no time left in this idle period
currentDidTimeout is false means the schedule is not timeout
what relationship between them, why does unstable_shouldYield() depend on them?
The text was updated successfully, but these errors were encountered: