Skip to content

chore(codemods/react/19/replace-default-props): sync React 19 replace-default-props improvements #62

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

Merged
merged 4 commits into from
Feb 19, 2025

Conversation

amirabbas-gh
Copy link
Collaborator

📚 Description

This PR syncs improvements to the replace-default-props codemod from reactjs/react-codemod#331, ensuring better handling of default props migration in React 19.

The key enhancements include:

  • Fix for non-destructured cases: Ensures proper transformation when default props are not destructured.
  • Fix for rest element cases: Correctly handles cases where the component uses rest elements.
  • Prevent unnecessary re-renders: Hoists default object values outside function parameters to avoid invalidating memoization, addressing a common issue when replacing .defaultProps with function parameters.

These improvements make the migration process more reliable and performant, especially for complex prop types.

🔗 Linked Issue

🧪 Test Plan

  1. Run npm run test for running codemod tests

@amirabbas-gh amirabbas-gh changed the title chore(react-codemod): sync React 19 replace-default-props improvements chore(codemods/react/19/replace-default-props): sync React 19 replace-default-props improvements Feb 19, 2025
@amirabbas-gh amirabbas-gh merged commit 8cf415e into main Feb 19, 2025
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.

2 participants