How to use the @emotion/core.withEmotionCache function in @emotion/core

To help you get started, we’ve selected a few @emotion/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emotion-js / emotion / packages / styled-base / src / index.js View on Github external
if (process.env.NODE_ENV !== 'production' && args[0][0] === undefined) {
        console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR)
      }
      styles.push(args[0][0])
      let len = args.length
      let i = 1
      for (; i < len; i++) {
        if (process.env.NODE_ENV !== 'production' && args[0][i] === undefined) {
          console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR)
        }
        styles.push(args[i], args[0][i])
      }
    }

    // $FlowFixMe: we need to cast StatelessFunctionalComponent to our PrivateStyledComponent class
    const Styled: PrivateStyledComponent<p> = withEmotionCache(
      (props, context, ref) =&gt; {
        return (
          
            {theme =&gt; {
              const finalTag = (shouldUseAs &amp;&amp; props.as) || baseTag

              let className = ''
              let classInterpolations = []
              let mergedProps = props
              if (props.theme == null) {
                mergedProps = {}
                for (let key in props) {
                  mergedProps[key] = props[key]
                }
                mergedProps.theme = theme
              }</p>
github emotion-js / emotion / packages / core / types / tests.tsx View on Github external
css,
  jsx,
  keyframes,
  withEmotionCache
} from '@emotion/core'
;

interface TestTheme0 {
  resetStyle: any
}

; [theme.resetStyle]} /&gt;

declare const getRandomColor: () =&gt; string

const ComponentWithCache = withEmotionCache((_props: {}, context) =&gt; {
  return (
    <div>
        context.sheet.insert(`div { backgroundColor: ${getRandomColor()} }`)
      }
    /&gt;
  )
})
; {}} /&gt;
;<div>
  <h1>
    This is really big</h1></div></div>