UNPKG

377 BJavaScriptView Raw
1import * as React from 'react'
2
3const isBrowser = typeof document !== 'undefined'
4
5const useInsertionEffect = React['useInsertion' + 'Effect']
6 ? React['useInsertion' + 'Effect']
7 : function useInsertionEffect(create) {
8 create()
9 }
10
11export default function useInsertionEffectMaybe(create) {
12 if (!isBrowser) {
13 return create()
14 }
15 useInsertionEffect(create)
16}