<commit_before>// @flow
import * as React from 'react'
import { renderToString } from 'react-dom/server'
import { extractCritical } from '@emotion/server'
import { cache } from '@emotion/css'
import { CacheProvider } from '@emotion/react'

export const replaceRenderer = ({
  replaceBodyHTMLString,
  bodyComponent,
  setHeadComponents
}: *) => {
  let { html, ids, css } = extractCritical(
    renderToString(<CacheProvider value={cache}>{bodyComponent}</CacheProvider>)
  )
  setHeadComponents([
    <style
      key="emotion"
      data-emotion-css={ids.join(' ')}
      dangerouslySetInnerHTML={{
        __html: css
      }}
    />
  ])
  replaceBodyHTMLString(html)
}
<commit_msg>Fixes gatsby plugin to avoid duplicated styles<commit_after>// @flow
import * as React from 'react'
import { renderToString } from 'react-dom/server'
import { extractCritical } from '@emotion/server'
import { cache } from '@emotion/css'
import { CacheProvider } from '@emotion/react'

export const replaceRenderer = ({
  replaceBodyHTMLString,
  bodyComponent,
  setHeadComponents
}: *) => {
  let { html, ids, css } = extractCritical(
    renderToString(<CacheProvider value={cache}>{bodyComponent}</CacheProvider>)
  )
  setHeadComponents([
    <style
      key="emotion"
      data-emotion={`css ${ids.join(' ')}`}
      dangerouslySetInnerHTML={{
        __html: css
      }}
    />
  ])
  replaceBodyHTMLString(html)
}

{'fraction_non_alphanumeric': 0.1347517730496454, 'fraction_numerical': 0.0, 'mean_word_length': 3.8823529411764706, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2651083', 'n_tokens_mistral': 432, 'n_tokens_neox': 422, 'n_words': 95}