Potential useContextProps
type compatibility issue with React 19 refs
#8451
-
Hello ! 👋 I'm experiencing a type compatibility issue between the The Problem: Example: import { createContext, type ComponentProps } from 'react'
import { type ContextValue, Button as RACButton, useContextProps } from 'react-aria-components'
interface StyleProps {
variant?: 'filled' | 'outlined' | 'ghost'
intent?: 'neutral' | 'accent' | 'success' | 'warning' | 'critical' | 'info'
size?: 'xs' | 'sm' | 'md' | 'lg'
}
interface ButtonProps extends ComponentProps<typeof RACButton>, StyleProps {}
const ButtonContext = createContext<ContextValue<Partial<ButtonProps>, HTMLButtonElement>>(null)
function Button({ ref, ...props }: ButtonProps) {
// TypeScript error: useContextProps expects ForwardedRef but React 19 provides Ref
[props, ref] = useContextProps(props, ref, ButtonContext)
// Some code...
return <RACButton ref={ref} {...props} />
} Question: Any guidance would be much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Looks like it needs an update, I've opened a PR here chore: Update react types |
Beta Was this translation helpful? Give feedback.
Looks like it needs an update, I've opened a PR here chore: Update react types