Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: React 19 support #2349

Draft
wants to merge 23 commits into
base: next
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2843b31
feat!: React 19 support
CodyJasonBennett Jan 2, 2025
8f36899
fix: remaining type errors
CodyJasonBennett Jan 2, 2025
4053dcc
chore: cleanup
CodyJasonBennett Jan 2, 2025
a3bd26d
docs: add missing react-use-measure dep
CodyJasonBennett Jan 2, 2025
a0652aa
chore: resolve conflicts
CodyJasonBennett Jan 8, 2025
f1b2617
docs: add missing use-gesture dep
CodyJasonBennett Jan 8, 2025
6cdab5e
chore: prefer JSX.IntrinsicElements for backwards compat
CodyJasonBennett Jan 8, 2025
a7fd0ac
chore: keep PropsWithRef for React 18
CodyJasonBennett Jan 8, 2025
f201223
chore(SpringContext): add React 18 backwards compat
CodyJasonBennett Jan 8, 2025
f25225d
fix(SpringContext): swap mutation target
CodyJasonBennett Jan 8, 2025
f3cef19
fix(SpringContext): typo
CodyJasonBennett Jan 8, 2025
9b12ea6
fix(SpringContext): feature check renderable context for consumer
CodyJasonBennett Jan 9, 2025
cafa5b8
chore: cleanup
CodyJasonBennett Jan 9, 2025
97b33db
experiment: revert dep upgrade
CodyJasonBennett Jan 9, 2025
20c7df5
experiment: restore dep upgrade
CodyJasonBennett Jan 9, 2025
6c06950
experiment: keep MutableRefObject
CodyJasonBennett Jan 10, 2025
33364f8
experiment: revert deps upgrade
CodyJasonBennett Jan 10, 2025
51312c3
Revert "experiment: keep MutableRefObject"
CodyJasonBennett Jan 10, 2025
59579e2
fix: add annotation for 18.3 immutable useRef
CodyJasonBennett Jan 10, 2025
a61d9e7
experiment: keep MutableRefObject
CodyJasonBennett Jan 10, 2025
983ca3f
experiment: upgrade deps to React 19
CodyJasonBennett Jan 10, 2025
c30d8a0
chore: upgrade to rc.2
CodyJasonBennett Jan 10, 2025
efda668
chore: cleanup
CodyJasonBennett Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: prefer JSX.IntrinsicElements for backwards compat
CodyJasonBennett committed Jan 8, 2025
commit 6cdab5edef98cf9b853137c97196519cfa6085af
5 changes: 2 additions & 3 deletions targets/three/src/animated.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { CSSProperties, ForwardRefExoticComponent, FC } from 'react'
import { CSSProperties, ForwardRefExoticComponent, FC, JSX } from 'react'
import {
AssignableKeys,
ComponentPropsWithRef,
ElementType,
} from '@react-spring/types'
import { FluidValue } from '@react-spring/shared'
import { Primitives } from './primitives'
import { ThreeElements } from '@react-three/fiber'

type AnimatedPrimitives = {
[P in Primitives]: AnimatedComponent<FC<ThreeElements[P]>>
[P in Primitives]: AnimatedComponent<FC<JSX.IntrinsicElements[P]>>
}

/** The type of the `animated()` function */
4 changes: 2 additions & 2 deletions targets/three/src/primitives.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as THREE from 'three'
import { ThreeElements } from '@react-three/fiber'
import { JSX } from 'react'

export type Primitives = keyof ThreeElements
export type Primitives = keyof JSX.IntrinsicElements

export const primitives = ['primitive'].concat(
Object.keys(THREE)

Unchanged files with check annotations Beta

}
// The animated prop value of a React element
type AnimatedProp<T> = [T, T] extends [infer T, infer DT]

Check warning on line 31 in targets/zdog/src/animated.ts

GitHub Actions / Style Checks

'T' is defined but never used. Allowed unused vars must match /^_/u
? [DT] extends [never]
? never
: DT extends void
: never
// An animated object of style attributes
type AnimatedStyle<T> = [T, T] extends [infer T, infer DT]

Check warning on line 42 in targets/zdog/src/animated.ts

GitHub Actions / Style Checks

'T' is defined but never used. Allowed unused vars must match /^_/u
? DT extends void
? undefined
: [DT] extends [never]
config: { mass: 20, tension: 150, friction: 50 }
}))
React.useEffect(() => void setInterval(() => api.start((i) => ({ ...random(i), delay: i * 40 })), 3000), [])

Check warning on line 34 in demo/src/sandboxes/springy-boxes/src/App.tsx

GitHub Actions / Style Checks

React Hook React.useEffect has a missing dependency: 'api'. Either include it or remove the dependency array
return (
<>
// Create a local ref if a props function or deps array is ever passed.
const ref = useMemo(
() => (propsFn || arguments.length == 3 ? SpringRef() : void 0),
[]

Check warning on line 85 in packages/core/src/hooks/useSprings.ts

GitHub Actions / Style Checks

React Hook useMemo has a missing dependency: 'propsFn'. Either include it or remove the dependency array
)
interface State {
})
},
}),
[]

Check warning on line 127 in packages/core/src/hooks/useSprings.ts

GitHub Actions / Style Checks

React Hook useMemo has a missing dependency: 'forceUpdate'. Either include it or remove the dependency array
)
const ctrls = useRef([...state.ctrls])
ctrls.current.length = length
declareUpdates(prevLength, length)
}, [length])

Check warning on line 147 in packages/core/src/hooks/useSprings.ts

GitHub Actions / Style Checks

React Hook useMemo has missing dependencies: 'declareUpdates', 'prevLength', and 'ref'. Either include them or remove the dependency array
// Update existing controllers when "deps" are changed.
useMemo(() => {
declareUpdates(0, Math.min(prevLength, length))
// @ts-expect-error – we want to allow passing undefined to useMemo
}, deps)

Check warning on line 153 in packages/core/src/hooks/useSprings.ts

GitHub Actions / Style Checks

React Hook useMemo was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies

Check warning on line 153 in packages/core/src/hooks/useSprings.ts

GitHub Actions / Style Checks

React Hook useMemo has missing dependencies: 'declareUpdates', 'length', and 'prevLength'. Either include them or remove the dependency array
/** Fill the `updates` array with declarative updates for the given index range. */
function declareUpdates(startIndex: number, endIndex: number) {
// Return a `SpringRef` if a deps array was passed.
const ref = useMemo(
() => (propsFn || arguments.length == 3 ? SpringRef() : void 0),
[]

Check warning on line 94 in packages/core/src/hooks/useTransition.tsx

GitHub Actions / Style Checks

React Hook useMemo has a missing dependency: 'propsFn'. Either include it or remove the dependency array
)
// Every item has its own transition.
(start: StartFn<T>, stop: StopFn<T>): Promise<any> | void
}
type StartFn<T> = InferTarget<T> extends { start: infer T } ? T : never

Check warning on line 35 in packages/core/src/types/functions.ts

GitHub Actions / Style Checks

'T' is defined but never used. Allowed unused vars must match /^_/u
type StopFn<T> = InferTarget<T> extends { stop: infer T } ? T : never
/**