react-codemod
react-codemod copied to clipboard
feat: add react 19 codemods
- adds 7 react 19 codemods
- adds ability to run ts transfroms from
react-codemodCLI
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>
h/t @r4zendev @DmytroHryshyn , and @hbjORbj for creating the React 19 codemods.
@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.
@DmytroHryshyn can you allow edits to the PR?
@DmytroHryshyn can you allow edits to the PR?
Sure, added you to the repo @rickhanlonii
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!
noted. we will remove it soon. thanks for flagging.
Thanks!