From 8d0ded8a9989a37d9f058c89503d176cf7686519 Mon Sep 17 00:00:00 2001 From: Robert Jarske Eriksson Date: Wed, 21 May 2025 07:43:06 +0200 Subject: [PATCH 1/6] fix: remove accessing elem.ref in renderTransitions for react v19 --- packages/core/src/hooks/useTransition.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/src/hooks/useTransition.tsx b/packages/core/src/hooks/useTransition.tsx index 8acf4e182c..b7c927a59a 100644 --- a/packages/core/src/hooks/useTransition.tsx +++ b/packages/core/src/hooks/useTransition.tsx @@ -436,7 +436,6 @@ export function useTransition( ) : ( elem From 71d07a22efda2e8f146c1a2c6d76fdd360bbdde8 Mon Sep 17 00:00:00 2001 From: Robert Jarske Eriksson Date: Wed, 21 May 2025 09:41:57 +0200 Subject: [PATCH 2/6] add version check --- packages/core/src/hooks/useTransition.tsx | 2 ++ tsconfig.json | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/src/hooks/useTransition.tsx b/packages/core/src/hooks/useTransition.tsx index b7c927a59a..23822efaa5 100644 --- a/packages/core/src/hooks/useTransition.tsx +++ b/packages/core/src/hooks/useTransition.tsx @@ -1,4 +1,5 @@ import * as React from 'react' +import { version as reactVersion } from 'react/package.json' import { useContext, useRef, useMemo } from 'react' import { Lookup, OneOrMore, UnknownProps } from '@react-spring/types' import { @@ -436,6 +437,7 @@ export function useTransition( ) : ( elem diff --git a/tsconfig.json b/tsconfig.json index 5b8125dac9..0a2c1ed287 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,6 +26,7 @@ "allowSyntheticDefaultImports": true, "esModuleInterop": true, "skipLibCheck": true, - "strictNullChecks": true + "strictNullChecks": true, + "resolveJsonModule": true } } From c88778c91c8c0f9574c7af5830a7fdbcd4af4e37 Mon Sep 17 00:00:00 2001 From: Robert Jarske Eriksson Date: Wed, 21 May 2025 12:56:26 +0200 Subject: [PATCH 3/6] revert package.json check in favor of React.version --- packages/core/src/hooks/useTransition.tsx | 3 +-- tsconfig.json | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/core/src/hooks/useTransition.tsx b/packages/core/src/hooks/useTransition.tsx index 23822efaa5..5594f2b2ed 100644 --- a/packages/core/src/hooks/useTransition.tsx +++ b/packages/core/src/hooks/useTransition.tsx @@ -1,5 +1,4 @@ import * as React from 'react' -import { version as reactVersion } from 'react/package.json' import { useContext, useRef, useMemo } from 'react' import { Lookup, OneOrMore, UnknownProps } from '@react-spring/types' import { @@ -437,7 +436,7 @@ export function useTransition( ) : ( elem diff --git a/tsconfig.json b/tsconfig.json index 0a2c1ed287..5b8125dac9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,7 +26,6 @@ "allowSyntheticDefaultImports": true, "esModuleInterop": true, "skipLibCheck": true, - "strictNullChecks": true, - "resolveJsonModule": true + "strictNullChecks": true } } From 14363ad24fdaa191dd8aeda8fd0c2291ebd217b9 Mon Sep 17 00:00:00 2001 From: Robert Jarske Eriksson Date: Fri, 23 May 2025 10:17:47 +0200 Subject: [PATCH 4/6] improve readability and add conditional ref prop to element --- packages/core/src/hooks/useTransition.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/core/src/hooks/useTransition.tsx b/packages/core/src/hooks/useTransition.tsx index 5594f2b2ed..786875d143 100644 --- a/packages/core/src/hooks/useTransition.tsx +++ b/packages/core/src/hooks/useTransition.tsx @@ -432,14 +432,18 @@ export function useTransition( {transitions.map((t, i) => { const { springs } = changes.get(t) || t.ctrl const elem: any = render({ ...springs }, t.item, t, i) - return elem && elem.type ? ( + + if (!elem || !elem.type) return elem + + const key = is.str(t.key) || is.num(t.key) ? t.key : t.ctrl.id + const isLegacyReact = React.version < '19.0.0' + + return ( - ) : ( - elem ) })} From ba46159f4a269ef856dc96a2080391547b183b4d Mon Sep 17 00:00:00 2001 From: Robert Jarske Eriksson Date: Fri, 23 May 2025 14:13:04 +0200 Subject: [PATCH 5/6] remove faulty conditional --- packages/core/src/hooks/useTransition.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/core/src/hooks/useTransition.tsx b/packages/core/src/hooks/useTransition.tsx index 786875d143..8f88e02212 100644 --- a/packages/core/src/hooks/useTransition.tsx +++ b/packages/core/src/hooks/useTransition.tsx @@ -433,18 +433,18 @@ export function useTransition( const { springs } = changes.get(t) || t.ctrl const elem: any = render({ ...springs }, t.item, t, i) - if (!elem || !elem.type) return elem - const key = is.str(t.key) || is.num(t.key) ? t.key : t.ctrl.id const isLegacyReact = React.version < '19.0.0' - return ( - - ) + const props = { + ...elem.props, + } + + if (isLegacyReact) { + props.ref = elem.ref + } + + return elem && elem.type ? : elem })} ) From 3a62f3ee8a869b7db5cb0082f2503c464af4c46c Mon Sep 17 00:00:00 2001 From: Robert Jarske Eriksson Date: Sat, 24 May 2025 19:58:02 +0200 Subject: [PATCH 6/6] set props assignment to empty object if elem or elem.props is nullish --- packages/core/src/hooks/useTransition.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/core/src/hooks/useTransition.tsx b/packages/core/src/hooks/useTransition.tsx index 8f88e02212..940b55e6ee 100644 --- a/packages/core/src/hooks/useTransition.tsx +++ b/packages/core/src/hooks/useTransition.tsx @@ -436,9 +436,7 @@ export function useTransition( const key = is.str(t.key) || is.num(t.key) ? t.key : t.ctrl.id const isLegacyReact = React.version < '19.0.0' - const props = { - ...elem.props, - } + const props = elem?.props ?? {} if (isLegacyReact) { props.ref = elem.ref