feat: v19 codemods: removing memoization hooks, useContext to use, context initialization expression conversion, ref property access #319
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
React v19 codemods
Summary
This PR contributes 4 new codemods to
react-codemods
repository, designed to streamline migration to a new React version that is going to have built-in compiler optimization features and a set of other semantic changes. Each codemod has its own description in the README file but below is a summary:useContext
hook conversion touse
hook.<Context.Provider value={defaultContextValue}>
typical context initialization expression conversion to cleaner<Context value={defaultContextValue}>
.ref
property access passed viaforwardRef
function wrapper conversion to destructure theref
property from theprops
object, as per latest changelog.Codemod Platform
Codemod is an open-source platform that makes it easy for developers to build, share, and run codemods with a free-forever and open-source set of toolings such as Codemod Studio, CLI and VS Code Extension. Codemod platform offers an enhanced user experience, including simplified setup, execution, and access to extended list of features like the following:
Running the Codemods
Via Codemod CLI
npm install -g codemod
to install Codemod.com's official CLI applicationcodemod list
to locate the list of available codemodscodemod <codemod-name>
(for example:codemod react/19/use-context-hook
) to run the codemodOr just simply run:
By default, the current path where you run the codemod will be used as the target folder to be processed. For advanced configurations of Codemod CLI, please refer to the (https://docs.codemod.com/deploying-codemods/cli)
Using react-codemods repository
Name should be specified as in the repository itself on GitHub.
For more details about how to run the codemods using the repository this PR is intended for, refer to the README file in the root of the repository.