Skip to content

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.

3 participants