Skip to content

Commit 197e0a7

Browse files
authored
fix: remove accessing elem.ref in renderTransitions (#2373)
1 parent 2dec583 commit 197e0a7

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

packages/core/src/hooks/useTransition.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -432,15 +432,17 @@ export function useTransition(
432432
{transitions.map((t, i) => {
433433
const { springs } = changes.get(t) || t.ctrl
434434
const elem: any = render({ ...springs }, t.item, t, i)
435-
return elem && elem.type ? (
436-
<elem.type
437-
{...elem.props}
438-
key={is.str(t.key) || is.num(t.key) ? t.key : t.ctrl.id}
439-
ref={elem.ref}
440-
/>
441-
) : (
442-
elem
443-
)
435+
436+
const key = is.str(t.key) || is.num(t.key) ? t.key : t.ctrl.id
437+
const isLegacyReact = React.version < '19.0.0'
438+
439+
const props = elem?.props ?? {}
440+
441+
if (isLegacyReact) {
442+
props.ref = elem.ref
443+
}
444+
445+
return elem && elem.type ? <elem.type key={key} {...props} /> : elem
444446
})}
445447
</>
446448
)

0 commit comments

Comments
 (0)