Skip to content
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

Add react 19 codemods and recommend codemod command #320

Merged
merged 21 commits into from
May 20, 2024

Conversation

DmytroHryshyn
Copy link
Contributor

@DmytroHryshyn DmytroHryshyn commented Apr 30, 2024

  • adds 7 react 19 codemods
  • adds ability to run ts transfroms from react-codemod CLI

Testing

Running with react-codemod

npx react-codemod remove-context-provider <path>
npx react-codemod replace-string-ref <path>
npx react-codemod remove-forward-ref <path>
npx react-codemod replace-use-form-state <path>
npx react-codemod use-context-hook <path>
npx react-codemod remove-memoization <path>
npx react-codemod replace-act-import <path>

Running with codemod

npx codemod react/19/remove-context-provider --target <path>
npx codemod react/19/replace-string-ref --target <path>
npx codemod react/19/remove-forward-ref --target <path>
npx codemod react/19/replace-use-form-state --target <path>
npx codemod react/19/use-context-hook --target <path>
npx codemod react/19/remove-memoization --target <path>
npx codemod react/19/replace-act-import --target <path>

@DmytroHryshyn DmytroHryshyn marked this pull request as draft April 30, 2024 17:14
@DmytroHryshyn DmytroHryshyn changed the title Codemods v3 feat: add react 19 codemods Apr 30, 2024
@alexbit-codemod
Copy link

alexbit-codemod commented Apr 30, 2024

h/t @r4zendev @DmytroHryshyn , and @hbjORbj for creating the React 19 codemods.

Co-authored-by: Benny Joo <[email protected]>
Co-authored-by: DmytroHryshyn <[email protected]>
Co-authored-by: Sasha <[email protected]>
@DmytroHryshyn DmytroHryshyn marked this pull request as ready for review May 1, 2024 16:56
@alexbit-codemod
Copy link

alexbit-codemod commented May 2, 2024

@acdlite, @rickhanlonii, @gnoff, @eps1lon, could one of you review this please?
I'd like us to merge this PR as soon as possible, invite a few early adopters to test it even more before we market it more broadly. Thank you.

@rickhanlonii
Copy link
Member

@DmytroHryshyn can you allow edits to the PR?

@DmytroHryshyn
Copy link
Contributor Author

@DmytroHryshyn can you allow edits to the PR?

Sure, added you to the repo @rickhanlonii

@josephsavona
Copy link

josephsavona commented May 19, 2024

We do not recommend removing useMemo and use callback while the compiler is still experimental. The compiler may skip components for various reasons (violations of React’s rules, as-yet-unsupported syntax, etc) and a blanket codemod to remove all manual memoization could cause problems.

We strongly recommend waiting until the compiler is stable. We plan to provide a script that will only remove manual memoization where the compiler is running, skipping components/hooks where the compiler would bail out.

Let’s remove the “remove memoization” code of from the PR - thanks!

@alexbit-codemod
Copy link

noted. we will remove it soon. thanks for flagging.

Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

README.md Outdated

This will start an interactive wizard, and then run the specified transform.
We recommend using the [`codemod`](go.codemod.com/react-codemod) command for improved experience and support.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rickhanlonii do you prefer if this link goes to our github, upgrade recipe, all react 19 codemods in registry, or somewhere else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a preference, that was what the codemod team added in a previous commit on this PR

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@rickhanlonii rickhanlonii changed the title feat: add react 19 codemods Add react 19 codemods May 20, 2024
@rickhanlonii rickhanlonii changed the title Add react 19 codemods Add react 19 codemods and recommend codemod command May 20, 2024
@rickhanlonii rickhanlonii changed the title Add react 19 codemods and recommend codemod command Add react 19 codemods and recommend codemod command May 20, 2024
@rickhanlonii rickhanlonii merged commit db10da2 into reactjs:master May 20, 2024
@rickhanlonii
Copy link
Member

Thanks!

@rickhanlonii rickhanlonii deleted the codemods-v3 branch May 20, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants