forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: react v19 codemods #1
Open
r4zendev
wants to merge
11
commits into
main
Choose a base branch
from
codemods-v19
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 6 new codemods to the repository, designed to facilitate migration to React v19 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.act
method import transfer toreact
namespace.useFormState
method is going to be replaced withuseActionState
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:
Maintaining the codemods
Via this PR, we would like to transfer ownership of the future versions of these codemods to the react team, meaning that these codemods are possible to spread in the developers' world under your name and improve if needed. To iterate over these codemods and publish them to the registry to make them available for execution, please see our publishing documentation
Running the codemods
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-alpha
) 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 documentation