Skip to content

Commit

Permalink
fix(useSupported): use useIsomorphicLayoutEffect to prevent layout …
Browse files Browse the repository at this point in the history
…jitter
  • Loading branch information
vikiboss committed Jul 10, 2024
1 parent 04255e7 commit b53787a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/use-supported/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from 'react'
import { useIsomorphicLayoutEffect } from '../use-isomorphic-layout-effect'
import { useLatest } from '../use-latest'
import { useSafeState } from '../use-safe-state'

Expand All @@ -12,7 +12,7 @@ export function useSupported(callback: () => unknown, deps: DependencyList = [])

const latest = useLatest({ callback })

useEffect(() => {
useIsomorphicLayoutEffect(() => {
setIsSupported(Boolean(latest.current.callback()))
}, deps)

Expand Down

0 comments on commit b53787a

Please sign in to comment.