Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(flushMicroTasks): Fallback to no scheduler in case of exception
Closes #736
  • Loading branch information
MatanBobi committed Jul 8, 2020
commit 181b2ee4313cef4f0775a2926ff47c70af123e72
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