error-boundaries
Rename unstable_handleError to componentDidCatch in React class components and createClass component definitions.
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 unstable_handleError to componentDidCatch
npx codemod @react-new/error-boundaries
Rename unstable_handleError to componentDidCatch in React class components and createClass component definitions.
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 import React from "react";
2
3 export class ComponentOne extends React.Component {
4 unstable_handleError(error) {}
5 render() {
6 return <div />;
7 }
8 }
9
10 export class ComponentTwo extends React.Component {
11 unstable_handleError = error => {};
12 render() {
13 return <div />;
14 }
15 }
16