Skip to content

Commit f69b748

Browse files
dimitris-tsetsonisDTsejoshuaellis
authored
fix: ref access issue in jest and legacy react apps (#2394)
Co-authored-by: Dimitris Tsetsonis <[email protected]> Co-authored-by: Josh <[email protected]>
1 parent 8631391 commit f69b748

File tree

16 files changed

+127
-96
lines changed

16 files changed

+127
-96
lines changed

.changeset/khaki-rice-peel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@react-spring/core': patch
3+
---
4+
5+
Fix issue with Jest and legacy React apps using useTransition

.changeset/pre.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"mode": "pre",
3+
"tag": "beta",
4+
"initialVersions": {
5+
"@react-spring/demo": "1.0.0",
6+
"@react-spring/docs": "2.0.0",
7+
"@react-spring/animated": "10.0.2",
8+
"@react-spring/core": "10.0.2",
9+
"eslint-config-react-spring": "0.0.1",
10+
"@react-spring/parallax": "10.0.2",
11+
"@react-spring/rafz": "10.0.2",
12+
"react-spring": "10.0.1",
13+
"@react-spring/shared": "10.0.2",
14+
"@react-spring/types": "10.0.2",
15+
"@react-spring/konva": "10.0.2",
16+
"@react-spring/native": "10.0.2",
17+
"@react-spring/three": "10.0.2",
18+
"@react-spring/web": "10.0.2",
19+
"@react-spring/zdog": "10.0.2"
20+
},
21+
"changesets": [
22+
"khaki-rice-peel"
23+
]
24+
}

packages/animated/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-spring/animated",
3-
"version": "10.0.2",
3+
"version": "10.0.3-beta.0",
44
"description": "Animated component props for React",
55
"module": "./dist/react-spring_animated.legacy-esm.js",
66
"main": "./dist/cjs/index.js",
@@ -52,8 +52,8 @@
5252
"pack": "yarn pack"
5353
},
5454
"dependencies": {
55-
"@react-spring/shared": "~10.0.2",
56-
"@react-spring/types": "~10.0.2"
55+
"@react-spring/shared": "~10.0.3-beta.0",
56+
"@react-spring/types": "~10.0.3-beta.0"
5757
},
5858
"peerDependencies": {
5959
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"

packages/core/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-spring/core",
3-
"version": "10.0.2",
3+
"version": "10.0.3-beta.0",
44
"module": "./dist/react-spring_core.legacy-esm.js",
55
"main": "./dist/cjs/index.js",
66
"types": "./dist/react-spring_core.modern.d.mts",
@@ -55,9 +55,9 @@
5555
"pack": "yarn pack"
5656
},
5757
"dependencies": {
58-
"@react-spring/animated": "~10.0.2",
59-
"@react-spring/shared": "~10.0.2",
60-
"@react-spring/types": "~10.0.2"
58+
"@react-spring/animated": "~10.0.3-beta.0",
59+
"@react-spring/shared": "~10.0.3-beta.0",
60+
"@react-spring/types": "~10.0.3-beta.0"
6161
},
6262
"peerDependencies": {
6363
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"

packages/core/src/hooks/useTransition.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,13 @@ export function useTransition(
438438

439439
const props = elem?.props ?? {}
440440

441-
if (isLegacyReact) {
442-
props.ref = elem.ref
443-
}
441+
const elemRef = isLegacyReact ? elem?.ref : props?.ref
444442

445-
return elem && elem.type ? <elem.type key={key} {...props} /> : elem
443+
return elem && elem.type ? (
444+
<elem.type {...props} key={key} ref={elemRef} />
445+
) : (
446+
elem
447+
)
446448
})}
447449
</>
448450
)

packages/parallax/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-spring/parallax",
3-
"version": "10.0.2",
3+
"version": "10.0.3-beta.0",
44
"module": "./dist/react-spring_parallax.legacy-esm.js",
55
"main": "./dist/cjs/index.js",
66
"types": "./dist/react-spring_parallax.modern.d.mts",
@@ -52,8 +52,8 @@
5252
"test": "vite serve ./test"
5353
},
5454
"dependencies": {
55-
"@react-spring/shared": "~10.0.2",
56-
"@react-spring/web": "~10.0.2"
55+
"@react-spring/shared": "~10.0.3-beta.0",
56+
"@react-spring/web": "~10.0.3-beta.0"
5757
},
5858
"peerDependencies": {
5959
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",

packages/rafz/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-spring/rafz",
3-
"version": "10.0.2",
3+
"version": "10.0.3-beta.0",
44
"description": "react-spring's fork of rafz one frameloop to rule them all",
55
"module": "./dist/react-spring_rafz.legacy-esm.js",
66
"main": "./dist/cjs/index.js",

packages/react-spring/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-spring",
3-
"version": "10.0.1",
3+
"version": "10.0.2-beta.0",
44
"module": "./dist/react-spring.legacy-esm.js",
55
"main": "./dist/cjs/index.js",
66
"types": "./dist/react-spring.modern.d.mts",
@@ -44,12 +44,12 @@
4444
"Josh Ellis (https://github.com/joshuaellis)"
4545
],
4646
"dependencies": {
47-
"@react-spring/core": "~10.0.1",
48-
"@react-spring/konva": "~10.0.1",
49-
"@react-spring/native": "~10.0.1",
50-
"@react-spring/three": "~10.0.1",
51-
"@react-spring/web": "~10.0.1",
52-
"@react-spring/zdog": "~10.0.1"
47+
"@react-spring/core": "~10.0.3-beta.0",
48+
"@react-spring/konva": "~10.0.3-beta.0",
49+
"@react-spring/native": "~10.0.3-beta.0",
50+
"@react-spring/three": "~10.0.3-beta.0",
51+
"@react-spring/web": "~10.0.3-beta.0",
52+
"@react-spring/zdog": "~10.0.3-beta.0"
5353
},
5454
"peerDependencies": {
5555
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",

packages/shared/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-spring/shared",
3-
"version": "10.0.2",
3+
"version": "10.0.3-beta.0",
44
"description": "Globals and shared modules",
55
"module": "./dist/react-spring_shared.legacy-esm.js",
66
"main": "./dist/cjs/index.js",
@@ -45,8 +45,8 @@
4545
"Josh Ellis (https://github.com/joshuaellis)"
4646
],
4747
"dependencies": {
48-
"@react-spring/rafz": "~10.0.2",
49-
"@react-spring/types": "~10.0.2"
48+
"@react-spring/rafz": "~10.0.3-beta.0",
49+
"@react-spring/types": "~10.0.3-beta.0"
5050
},
5151
"peerDependencies": {
5252
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"

packages/types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-spring/types",
3-
"version": "10.0.2",
3+
"version": "10.0.3-beta.0",
44
"description": "Internal package with TypeScript stuff",
55
"module": "./dist/react-spring_types.legacy-esm.js",
66
"main": "./dist/cjs/index.js",

0 commit comments

Comments
 (0)