-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add warning if multiple versions are running (addresses #1470)
- Loading branch information
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
// @flow | ||
export let isBrowser = typeof document !== 'undefined' | ||
|
||
const globalKey = '__EMOTION_CORE__' | ||
const globalContext = isBrowser ? window : global | ||
|
||
export function checkForMultipleVersions() { | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (globalContext[globalKey]) { | ||
console.warn( | ||
'You are loading @emotion/core when it is already loaded. Running' + | ||
'multiple instances may cause problems. This can happen if multiple ' + | ||
'versions are used, or if multiple builds of the same version are ' + | ||
'used.' | ||
) | ||
} | ||
globalContext[globalKey] = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters