rename-unsafe-lifecycles
Rename deprecated React lifecycle names to their UNSAFE_ equivalents in class components, object literals, and member references.
Usage
bash
Development
bash
Explore community-led codemods to migrate, optimize, and transform your codebase.
Build your own codemod and share it with the community.
Rename deprecated lifecycle methods to UNSAFE_ prefixed versions
npx codemod @react-new/rename-unsafe-lifecycles
Rename deprecated React lifecycle names to their UNSAFE_ equivalents in class components, object literals, and member references.
bash
bash
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
3 class Component extends React.Component {
4 componentWillMount() {
5 this.componentWillReceiveProps(this.props);
6 }
7 componentWillReceiveProps() {}
8 render() {
9 return null;
10 }
11 }