react icon indicating copy to clipboard operation
react copied to clipboard

[React 19] Need suggestion on upgrade.

Open lakshman0369 opened this issue 1 year ago • 2 comments

Summary

We are upgrading the react in our project and we see in the documentation the support for the defaultprops and proptypes is removed.

We are using the jsx and migrating to typescript is not possible at the moment as our project is fairly big. Any suggestion on how to do defaultprop and proptype check.

lakshman0369 avatar Sep 02 '24 06:09 lakshman0369

You can use defaultprops and proptypes on your component or you can try JSDoc comments

VDXD avatar Sep 02 '24 17:09 VDXD

Here is something I came up with, along with some help form my AI agent. This is the short version - if you want the long one, let me know:

  • Use ES6 default parameters for setting default values in your functional components.
  • Continue using prop-types for runtime validation of props to prevent passing incorrect data types.
  • Plan for a gradual migration to TypeScript, as that will ultimately offer the strongest and most scalable type safety long-term.

AlexTodorov11 avatar Sep 29 '24 13:09 AlexTodorov11

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Dec 28 '24 14:12 github-actions[bot]

You can use defaultProps and PropTypes with function components by utilizing React.memo and prop-types libraries

iashokk avatar Dec 29 '24 16:12 iashokk

@lakshman0369 see https://github.com/facebook/react/issues/28992#issuecomment-2862341940

@NikolayFrantsev created a babale plugin that helps to reinstate propTypes and you can migrate defaultProps using npx codemod@latest react/19/replace-default-props

Gnative avatar May 08 '25 09:05 Gnative

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Sep 13 '25 02:09 github-actions[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

github-actions[bot] avatar Sep 20 '25 02:09 github-actions[bot]