Definition
Recipes15
- Upgrade to React 18
- Remove
React.forwardRefwrapper - Remove
React.FCtype annotation - Replace
actimport from react-dom/test-utils - Remove
Context.Providerwrapper - Replace
useContextwithuse - Replace
useFormStatewithuseActionState - Replace string refs with callback refs
- Replace
defaultPropswith default parameter values - Replace
ReactDOM.hydratewithhydrateRoot - Add initial value to
useRef()calls - Remove
propTypesassignments - Remove implicit ref callback returns
- Replace deprecated React types
- Replace
react-test-renderer/shallowimport
Usage
Run this recipe
In order to run JavaScript recipes, you will need to use the Moderne CLI. For JavaScript specific configuration instructions, please see our configuring JavaScript guide.
Once the CLI is installed, you can install this JavaScript recipe package by running the following command:
Install the recipe package
mod config recipes npm install @openrewrite/recipes-react
Then, you can run the recipe via:
Run the recipe
mod run . --recipe org.openrewrite.react.migrate.upgrade-to-react-19