Skip to content

Commit

Permalink
fix(flushMicroTasks): Fallback to no scheduler in case of exception
Browse files Browse the repository at this point in the history
  • Loading branch information
MatanBobi committed Jul 8, 2020
1 parent 47e6da6 commit 181b2ee
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/flush-microtasks.js
Original file line number Diff line number Diff line change
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,
})

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
}
}
}

Expand Down

0 comments on commit 181b2ee

Please sign in to comment.