Skip to content

Commit

Permalink
fix(useCssVar): use useLayoutMount to prevent layout jitter
Browse files Browse the repository at this point in the history
  • Loading branch information
vikiboss committed Jul 10, 2024
1 parent 5a58843 commit 7935a16
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/use-css-var/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useLatest } from '../use-latest'
import { useMount } from '../use-mount'
import { useLayoutMount } from '../use-layout-mount'
import { useMutationObserver } from '../use-mutation-observer'
import { useSafeState } from '../use-safe-state'
import { useStableFn } from '../use-stable-fn'
Expand Down Expand Up @@ -63,7 +63,7 @@ export function useCssVar<T extends HTMLElement = HTMLElement>(
_setVariable(value)
})

useMount(() => void getPropertyValue())
useLayoutMount(() => void getPropertyValue())

useMutationObserver(observe ? el : null, getPropertyValue, { attributes: true })

Expand Down

0 comments on commit 7935a16

Please sign in to comment.