Skip to content

Commit

Permalink
Add warning if multiple versions are running (addresses #1470)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs139 committed Dec 19, 2019
1 parent 456be9a commit 9955147
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions packages/core/src/utils.js
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
}
}
2 changes: 1 addition & 1 deletion packages/utils/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import type { RegisteredCache, EmotionCache, SerializedStyles } from './types'

let isBrowser = typeof document !== 'undefined'
const isBrowser = typeof document !== 'undefined'

export function getRegisteredStyles(
registered: RegisteredCache,
Expand Down

0 comments on commit 9955147

Please sign in to comment.