react-proptypes-to-prop-types
Replace legacy React PropTypes usage with the prop-types package across imports, requires, aliases, and destructuring patterns.
Usage
bash
To override the prop-types module specifier, pass --param module-name=<value>.
Explore community-led codemods to migrate, optimize, and transform your codebase.
Build your own codemod and share it with the community.
Replace React.PropTypes with prop-types package
npx codemod react-proptypes-to-prop-types
Replace legacy React PropTypes usage with the prop-types package across imports, requires, aliases, and destructuring patterns.
bash
To override the prop-types module specifier, pass --param module-name=<value>.
This is one example from the codemod's test cases. The codemod may handle many more cases.
Build your own codemod and share it with the community.
1 const React = require('react');
2 const { Component, PropTypes: PT } = React;
3
4 class ClassComponent extends Component {
5 static propTypes = {
6 foo: PT.string.isRequired,
7 }
8 }
9