Skip to content

Commit baa0f5f

Browse files
author
Dustin Masters
committed
Fix crash during server-render in non-Node environments.
setTimeout and clearTimeout may not be available in some server-render environments (such as ChakraCore in React.NET), and loading ReactScheduler.js will cause a crash unless the existence of the variables are checked via a typeof comparison. reactjs/React.NET#555
1 parent 5b3d17a commit baa0f5f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/react-scheduler/src/ReactScheduler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ if (__DEV__) {
6060
// this module is initially evaluated.
6161
// We want to be using a consistent implementation.
6262
const localDate = Date;
63-
const localSetTimeout = setTimeout;
64-
const localClearTimeout = clearTimeout;
63+
const localSetTimeout = typeof setTimeout === 'function' ? setTimeout : null;
64+
const localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : null;
6565

6666
const hasNativePerformanceNow =
6767
typeof performance === 'object' && typeof performance.now === 'function';

0 commit comments

Comments
 (0)