-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Avoid importing Scheduler directly #14757
Conversation
The reconciler should not depend directly on Scheduler. This adds it to the host config for the renderer instead. (Except for `scheduler/tracing` imports, which are used only by the profiling build. I've left those imports as-is, though I'm open to directing those through the host config, too.)
@@ -210,6 +210,8 @@ export const shouldYield = TestRendererSchedulingShouldYield; | |||
export const scheduleTimeout = setTimeout; | |||
export const cancelTimeout = clearTimeout; | |||
export const noTimeout = -1; | |||
export const schedulePassiveEffects = scheduleDeferredCallback; | |||
export const cancelPassiveEffects = cancelDeferredCallback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a little weird now that we're exporting these multiple times with the same name ¯_(ツ)_/¯ Oh well though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right this change doesn't have much immediate impact, but gives us flexibility to customize the implementation in the future. For example, noop renderer already has a forked implementation.
flushPassiveEffects() { | ||
// Trick to flush passive effects without exposing an internal API: | ||
// Create a throwaway root and schedule a dummy update on it. | ||
const rootID = 'bloop'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nit: This is unlikely to conflict, but should we maybe pick something a little longer and more unique?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gotcha
Details of bundled changes.Comparing: 81470a0...e0ea64b react-test-renderer
react-noop-renderer
Generated by 🚫 dangerJS |
* Avoid importing Scheduler directly The reconciler should not depend directly on Scheduler. This adds it to the host config for the renderer instead. (Except for `scheduler/tracing` imports, which are used only by the profiling build. I've left those imports as-is, though I'm open to directing those through the host config, too.) * Make throwaway root id longer to appease Brian
The reconciler should not depend directly on Scheduler. This adds it to the host config for the renderer instead.
(Except for
scheduler/tracing
imports, which are used only by the profiling build. I've left those imports as-is, though I'm open to directing those through the host config, too.)