Skip to content
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

fix(flushMicroTasks): Fallback to no scheduler in case of exception #739

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/flush-microtasks.js
Expand Up @@ -20,7 +20,7 @@ function getIsUsingFakeTimers() {

const globalObj = typeof window === 'undefined' ? global : window
let Scheduler = globalObj.Scheduler
const isModernScheduleCallbackSupported = satisfies(React.version, '>16.8.6', {
let isModernScheduleCallbackSupported = satisfies(React.version, '>16.8.6', {
includePrerelease: true,
})
kentcdodds marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -58,6 +58,17 @@ try {
'if you encounter this warning.',
)
}

if (isModernScheduleCallbackSupported) {
// eslint-disable-next-line no-console
console.error(
'This environment does not support module requiring, so we cannot require the Scheduler. ' +
'To fix this you can require the Scheduler in your test setup file.',
)

// Fallback to no scheduleCallback Supported.
isModernScheduleCallbackSupported = false
}
}
}
kentcdodds marked this conversation as resolved.
Show resolved Hide resolved

Expand Down