From df3d53c9258b0f5819015367a452ef4ca29d817d Mon Sep 17 00:00:00 2001 From: garronej Date: Fri, 23 Jul 2021 14:36:13 +0200 Subject: [PATCH 1/3] expose __unsafe_useEmotionCache from @emotion/react --- packages/react/src/context.js | 5 +++++ packages/react/src/index.js | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/react/src/context.js b/packages/react/src/context.js index af267ce29..0620fb9e0 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 00e47ccff..5916634fe 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' From ae143e28c7c9d83072534a1cfe59f04b1cb482ad Mon Sep 17 00:00:00 2001 From: garronej Date: Fri, 23 Jul 2021 15:18:02 +0200 Subject: [PATCH 2/3] Upgrade Changesets --- .changeset/forty-pumas-refuse.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/forty-pumas-refuse.md diff --git a/.changeset/forty-pumas-refuse.md b/.changeset/forty-pumas-refuse.md new file mode 100644 index 000000000..a51538b34 --- /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 From ac6b36b936c31364d73982ff4292c86f1c8db675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sun, 8 Aug 2021 10:41:35 +0200 Subject: [PATCH 3/3] Update .changeset/forty-pumas-refuse.md --- .changeset/forty-pumas-refuse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/forty-pumas-refuse.md b/.changeset/forty-pumas-refuse.md index a51538b34..b4d5232b9 100644 --- a/.changeset/forty-pumas-refuse.md +++ b/.changeset/forty-pumas-refuse.md @@ -2,4 +2,4 @@ '@emotion/react': patch --- -expose \_\_unsafe_useEmotionCache from @emotion/react, see https://github.com/emotion-js/emotion/pull/2441 +Exposed `__unsafe_useEmotionCache` which can be used to access the current Emotion's cache in an easier way than before. Using this might break 0-config SSR and is not recommended to be used unless there you know what you are doing and you are OK with the mentioned downside.