Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply React composition patterns to build flexible, maintainable components without boolean prop sprawl
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/react19-no-forwardref.md
1---2title: React 19 API Changes3impact: MEDIUM4impactDescription: cleaner component definitions and context usage5tags: react19, refs, context, hooks6---78## React 19 API Changes910> **⚠️ React 19+ only.** Skip this if you're on React 18 or earlier.1112In React 19, `ref` is now a regular prop (no `forwardRef` wrapper needed), and `use()` replaces `useContext()`.1314**Incorrect (forwardRef in React 19):**1516```tsx17const ComposerInput = forwardRef<TextInput, Props>((props, ref) => {18return <TextInput ref={ref} {...props} />19})20```2122**Correct (ref as a regular prop):**2324```tsx25function ComposerInput({ ref, ...props }: Props & { ref?: React.Ref<TextInput> }) {26return <TextInput ref={ref} {...props} />27}28```2930**Incorrect (useContext in React 19):**3132```tsx33const value = useContext(MyContext)34```3536**Correct (use instead of useContext):**3738```tsx39const value = use(MyContext)40```4142`use()` can also be called conditionally, unlike `useContext()`.43