Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export the EmotionCacheContext #2418

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/real-geckos-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@emotion/react': patch
---

Export the EmotionCacheContext.
2 changes: 1 addition & 1 deletion packages/react/src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useContext, forwardRef } from 'react'
import createCache from '@emotion/cache'
import { isBrowser } from './utils'

let EmotionCacheContext: React.Context<EmotionCache | null> =
export let EmotionCacheContext: React.Context<EmotionCache | null> =
/* #__PURE__ */ React.createContext(
// we're doing this to avoid preconstruct's dead code elimination in this one case
// because this module is primarily intended for the browser and node
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import pkg from '../package.json'
export type { SerializedStyles } from '@emotion/utils'
export { withEmotionCache, CacheProvider } from './context'
export { withEmotionCache, CacheProvider, EmotionCacheContext } from './context'
export { jsx } from './jsx'
export { jsx as createElement } from './jsx'
export { Global } from './global'
Expand Down
6 changes: 2 additions & 4 deletions scripts/ssr-benchmarks/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let React = require('react')
let styled = require('@emotion/styled').default
let { renderToString } = require('react-dom/server')
let Benchmark = require('benchmark')
let { jsx, css, CacheProvider } = require('@emotion/react')
let { jsx, css, CacheProvider, EmotionCacheContext } = require('@emotion/react')
let { createTriangle } = require('./triangle')
let { css: cssClassName } = require('@emotion/css')
let { renderStylesToString } = require('@emotion/server')
Expand Down Expand Up @@ -70,13 +70,11 @@ let CssFuncTriangle = createTriangle(({ x, y, size, color, ...props }) => {
...props
})
})
// $FlowFixMe
let CacheContext = CacheProvider._context

let hasOwnProperty = Object.prototype.hasOwnProperty

let ExperimentTriangle = createTriangle(({ x, y, size, color, ...props }) => {
let cache = CacheContext._currentValue
let cache = EmotionCacheContext._currentValue

let className = ''
const serialized = css`
Expand Down