Skip to content

Commit 6b3a7c0

Browse files
committed
fix: avoid calling "useLayoutEffect" when SSR
1 parent 826b14e commit 6b3a7c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/core/src/useTransition.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, {
22
useRef,
33
useMemo,
4-
useLayoutEffect,
54
useImperativeHandle,
65
ReactNode,
76
RefObject,
@@ -10,6 +9,7 @@ import {
109
is,
1110
toArray,
1211
useForceUpdate,
12+
useIsomorphicLayoutEffect,
1313
useOnce,
1414
each,
1515
OneOrMore,
@@ -136,7 +136,7 @@ export function useTransition(
136136
// The "onRest" callbacks need a ref to the latest transitions.
137137
const usedTransitions = useRef<TransitionState[] | null>(null)
138138
const prevTransitions = usedTransitions.current
139-
useLayoutEffect(() => {
139+
useIsomorphicLayoutEffect(() => {
140140
usedTransitions.current = transitions
141141
})
142142

@@ -311,7 +311,7 @@ export function useTransition(
311311

312312
useImperativeHandle(ref, () => api)
313313

314-
useLayoutEffect(
314+
useIsomorphicLayoutEffect(
315315
() => {
316316
each(changes, ({ phase, payload }, t) => {
317317
t.phase = phase

0 commit comments

Comments
 (0)