Skip to content

Commit bee926b

Browse files
committed
fix: call useLayoutEffect in useTransition
1 parent 4fcf8c7 commit bee926b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/core/src/useTransition.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, {
2-
useEffect,
32
useRef,
3+
useMemo,
4+
useLayoutEffect,
45
useImperativeHandle,
56
ReactNode,
6-
useMemo,
77
} from 'react'
88
import { is, toArray, useForceUpdate, useOnce, each, OneOrMore } from 'shared'
99
import { now } from 'shared/globals'
@@ -52,7 +52,7 @@ export function useTransition<T>(data: OneOrMore<T>, props: any, deps?: any) {
5252
// The "onRest" callbacks need a ref to the latest transitions.
5353
const usedTransitions = useRef<Transition[] | null>(null)
5454
const prevTransitions = usedTransitions.current
55-
useEffect(() => {
55+
useLayoutEffect(() => {
5656
usedTransitions.current = transitions
5757
})
5858

@@ -223,7 +223,7 @@ export function useTransition<T>(data: OneOrMore<T>, props: any, deps?: any) {
223223

224224
useImperativeHandle(ref, () => api)
225225

226-
useEffect(
226+
useLayoutEffect(
227227
() => {
228228
each(changes, ({ phase, payload }, t) => {
229229
t.phase = phase

0 commit comments

Comments
 (0)