diff --git a/.changeset/forty-pumas-refuse.md b/.changeset/forty-pumas-refuse.md new file mode 100644 index 0000000000..a51538b345 --- /dev/null +++ b/.changeset/forty-pumas-refuse.md @@ -0,0 +1,5 @@ +--- +'@emotion/react': patch +--- + +expose \_\_unsafe_useEmotionCache from @emotion/react, see https://github.com/emotion-js/emotion/pull/2441 diff --git a/packages/react/src/context.js b/packages/react/src/context.js index af267ce29d..0620fb9e08 100644 --- a/packages/react/src/context.js +++ b/packages/react/src/context.js @@ -20,6 +20,11 @@ let EmotionCacheContext: React.Context = export let CacheProvider = EmotionCacheContext.Provider +export let __unsafe_useEmotionCache = + function useEmotionCache(): EmotionCache | null { + return useContext(EmotionCacheContext) + } + let withEmotionCache = function withEmotionCache>( func: (props: Props, cache: EmotionCache, ref: Ref) => React.Node ): React.AbstractComponent { diff --git a/packages/react/src/index.js b/packages/react/src/index.js index 00e47ccff4..5916634fea 100644 --- a/packages/react/src/index.js +++ b/packages/react/src/index.js @@ -1,7 +1,11 @@ // @flow import pkg from '../package.json' export type { SerializedStyles } from '@emotion/utils' -export { withEmotionCache, CacheProvider } from './context' +export { + withEmotionCache, + CacheProvider, + __unsafe_useEmotionCache +} from './context' export { jsx } from './jsx' export { jsx as createElement } from './jsx' export { Global } from './global'