We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 84522de commit eda5e68Copy full SHA for eda5e68
.changeset/hip-cherries-arrive.md
@@ -0,0 +1,5 @@
1
+---
2
+'@emotion/react': patch
3
4
+
5
+Fix error loading @emotion/react in alternative JS environments
packages/react/src/index.js
@@ -20,7 +20,14 @@ if (process.env.NODE_ENV !== 'production') {
20
const isJest = typeof jest !== 'undefined'
21
22
if (isBrowser && !isJest) {
23
- const globalContext = isBrowser ? window : global
+ // globalThis has wide browser support - https://caniuse.com/?search=globalThis, Node.js 12 and later
24
+ const globalContext =
25
+ // $FlowIgnore
26
+ typeof globalThis !== 'undefined'
27
+ ? globalThis // eslint-disable-line no-undef
28
+ : isBrowser
29
+ ? window
30
+ : global
31
const globalKey = `__EMOTION_REACT_${pkg.version.split('.')[0]}__`
32
if (globalContext[globalKey]) {
33
console.warn(
0 commit comments