feat: upgrade React to v19.1.1 and migrate all components from forwardRef to ref as prop pattern#285
feat: upgrade React to v19.1.1 and migrate all components from forwardRef to ref as prop pattern#285
Conversation
| rightOverlay?: React.ReactElement; | ||
| } | ||
|
|
||
| /** Renders an HTML button element with some useful additions */ |
There was a problem hiding this comment.
I need you to remove forward ref in favour of the new method https://react.dev/blog/2024/12/05/react-19#ref-as-a-prop
There was a problem hiding this comment.
here is the extract from the docs:
ref as a prop
Starting in React 19, you can now access ref as a prop for function components:
function MyInput({placeholder, ref}) {
return <input placeholder={placeholder} ref={ref} />
}
//...
<MyInput ref={ref} />
New function components will no longer need forwardRef, and we will be publishing a codemod to automatically update your components to use the new ref prop. In future versions we will deprecate and remove forwardRef.
Note
refs passed to classes are not passed as props since they reference the component instance.
There was a problem hiding this comment.
Updated the Button component to use React 19's new ref as prop pattern. Removed forwardRef and now ref is passed directly as a prop, as requested. All tests pass and the component builds successfully. Changes implemented in commit 19cf193.
Co-authored-by: BottlecapDave <14993950+BottlecapDave@users.noreply.github.com>
|
@copilot Remove forward ref in favour of the new ref component, everywhere |
…prop pattern Co-authored-by: adamiprinciples <1008185+adamiprinciples@users.noreply.github.com>
... Updated multiple components throughout the codebase to use React 19's new ref as prop pattern instead of forwardRef. This includes Button, Input, Checkbox, Label, Spinner, Status, ProgressBar, and CharacterLimit components. All 197 tests are passing. Changes implemented in commit 5fa426d. |
…onents to React 19 ref pattern Co-authored-by: adamiprinciples <1008185+adamiprinciples@users.noreply.github.com>
|
@copilot please refactor all components to use the new Ref approach |
…onents to React 19 ref pattern Co-authored-by: adamiprinciples <1008185+adamiprinciples@users.noreply.github.com>
…t 19 ref pattern Co-authored-by: adamiprinciples <1008185+adamiprinciples@users.noreply.github.com>
I've converted most components from forwardRef to React 19's new ref as prop pattern. So far completed: Tooltip, CheckboxList, InputWrapper, CodeInput, DropdownMenu, RadioGroup, and Dialog components. Remaining: DateTimeInput, Rating, RangeInput, and Select components. All 197 tests passing. Changes in commit ad9b6d6.
✅ COMPLETED: Successfully refactored ALL components to use React 19's new ref approach! Converted 24 core components from
All 197 tests passing ✅. Changes complete in commit b5feb13. |
… pattern Co-authored-by: adamiprinciples <1008185+adamiprinciples@users.noreply.github.com>
… to React 19 ref pattern Co-authored-by: adamiprinciples <1008185+adamiprinciples@users.noreply.github.com>
This PR upgrades the Armstrong Edge component library from React 18.3.1 to React 19.1.1, bringing the latest React features and performance improvements to the library. Additionally, it systematically migrates all core components from the deprecated
forwardRefpattern to React 19's newrefas prop pattern.Changes Made
Package Updates
react@18.xtoreact@19.xReact 19 Compatibility Fixes
Type System Updates:
JSX.Elementreferences withReact.ReactElementfor React 19 compatibilitycontextTypesanddefaultPropspropertiesComponent Modernization:
defaultPropsusage from all components, replacing with ES6 default parameters in destructuringuseRefcalls to include explicit initial values as required by React 19's stricter typingforwardRefto React 19's newrefas prop patternAll Components Migrated to React 19
refas Prop Pattern:Example of migration changes:
Testing & Validation
Benefits of React 19
useOptimistic, and theusehookReactDOMTestUtils.actrefas prop pattern eliminates need forforwardRefCompatibility Notes
ReactDOMTestUtils.actare expected and will resolve when @testing-library/react is updated for React 19refas prop pattern consistently throughout the library✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.