From addfc4cd50259873fd0e2df8d7b07767bcfdab93 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 4 Nov 2021 10:29:37 +0100 Subject: [PATCH] fix: document can be `null`, not just `undefined` --- packages/shared/invokeGuardedCallbackImpl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/invokeGuardedCallbackImpl.js b/packages/shared/invokeGuardedCallbackImpl.js index c33820080054a..9fcfbaaef0e93 100644 --- a/packages/shared/invokeGuardedCallbackImpl.js +++ b/packages/shared/invokeGuardedCallbackImpl.js @@ -81,7 +81,7 @@ if (__DEV__) { // when we call document.createEvent(). However this can cause confusing // errors: https://github.com/facebook/create-react-app/issues/3482 // So we preemptively throw with a better message instead. - if (typeof document === 'undefined') { + if (typeof document === 'undefined' || document === null) { throw new Error( 'The `document` global was defined when React was initialized, but is not ' + 'defined anymore. This can happen in a test environment if a component ' +