mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
fix(react-dom): Fix crash during server render (#14103)
Check for existence of `setTimeout` and `clearTimeout` in the runtime before using them, to ensure runtimes without them (like .NET ClearScript) do not crash just by importing `react-dom`.
This commit is contained in:
+7
-2
@@ -284,8 +284,13 @@ export function createTextInstance(
|
||||
}
|
||||
|
||||
export const isPrimaryRenderer = true;
|
||||
export const scheduleTimeout = setTimeout;
|
||||
export const cancelTimeout = clearTimeout;
|
||||
// This initialization code may run even on server environments
|
||||
// if a component just imports ReactDOM (e.g. for findDOMNode).
|
||||
// Some environments might not have setTimeout or clearTimeout.
|
||||
export const scheduleTimeout =
|
||||
typeof setTimeout === 'function' ? setTimeout : (undefined: any);
|
||||
export const cancelTimeout =
|
||||
typeof clearTimeout === 'function' ? clearTimeout : (undefined: any);
|
||||
export const noTimeout = -1;
|
||||
|
||||
// -------------------
|
||||
|
||||
Reference in New Issue
Block a user