Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
22 lines
637 B
Plaintext
22 lines
637 B
Plaintext
import * as React from 'react'
|
|
import isBrowser from '#is-browser'
|
|
|
|
const syncFallback = <T>(create: () => T) => create()
|
|
|
|
const useInsertionEffect = React[
|
|
('useInsertion' + 'Effect') as 'useInsertionEffect'
|
|
]
|
|
? (React[('useInsertion' + 'Effect') as 'useInsertionEffect'] as <T>(
|
|
create: () => T
|
|
) => T | undefined)
|
|
: false
|
|
|
|
export const useInsertionEffectAlwaysWithSyncFallback: <T>(
|
|
create: () => T
|
|
) => T | undefined = !isBrowser
|
|
? syncFallback
|
|
: useInsertionEffect || syncFallback
|
|
|
|
export const useInsertionEffectWithLayoutFallback: typeof React.useLayoutEffect =
|
|
useInsertionEffect || React.useLayoutEffect
|