Skip to content

Commit

Permalink
useInsertionEffect directly in Global
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Dec 14, 2024
1 parent ab928db commit 9717107
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/react/src/global.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as React from 'react'
import React from 'react'
import isDevelopment from '#is-development'
import { withEmotionCache } from './context'
import { Theme, ThemeContext } from './theming'
import { insertStyles } from '@emotion/utils'
import { Options as SheetOptions, StyleSheet } from '@emotion/sheet'
import isBrowser from '#is-browser'
import { useInsertionEffectWithLayoutFallback } from '@emotion/use-insertion-effect-with-fallbacks'

import { Interpolation, serializeStyles } from '@emotion/serialize'

Expand Down Expand Up @@ -86,7 +85,7 @@ export let Global = /* #__PURE__ */ withEmotionCache<GlobalProps>(
[sheet: StyleSheet, isRehydrating: boolean] | undefined
>(undefined)

useInsertionEffectWithLayoutFallback(() => {
React.useInsertionEffect(() => {
const key = `${cache.key}-global`

// use case of https://github.com/emotion-js/emotion/issues/2675
Expand Down Expand Up @@ -117,7 +116,7 @@ export let Global = /* #__PURE__ */ withEmotionCache<GlobalProps>(
}
}, [cache])

useInsertionEffectWithLayoutFallback(() => {
React.useInsertionEffect(() => {
let sheetRefCurrent = sheetRef.current!
let [sheet, rehydrating] = sheetRefCurrent
if (rehydrating) {
Expand Down

0 comments on commit 9717107

Please sign in to comment.