Skip to content

Added codemod for unstable_handleError -> componentDidCatch#158

Merged
bvaughn merged 2 commits intoreactjs:masterfrom
bvaughn:error-boundaries
Jul 17, 2017
Merged

Added codemod for unstable_handleError -> componentDidCatch#158
bvaughn merged 2 commits intoreactjs:masterfrom
bvaughn:error-boundaries

Conversation

@bvaughn
Copy link
Copy Markdown
Contributor

@bvaughn bvaughn commented Jul 17, 2017

React introduced the experimental "error boundaries" feature in version 15. Components define an unstable_handleError method to opt into this feature. Version 16 finalizes support for error boundaries, but with a new name- componentDidCatch.

This codemod is pretty simplistic. It renames all identifiers named unstable_handleError. At first (a8be6bb) I thought about restricting renamed identifiers to class properties/methods and object expressions. But that felt fragile. (What if a react component directly called its own unstable_handleError method? We'd want to rename the call too.) So I broadened it (411750c). The broader approach runs the possibility of false positives but I think the name is sufficiently unique that it's okay.

Relates to the "make error boundaries official" beta-blocker in facebook/react/issues/8854

@bvaughn bvaughn requested a review from flarnie July 17, 2017 19:44
@bvaughn
Copy link
Copy Markdown
Contributor Author

bvaughn commented Jul 17, 2017

cc @flarnie for review 😄

Copy link
Copy Markdown
Contributor

@flarnie flarnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!

@bvaughn bvaughn merged commit 437e6d5 into reactjs:master Jul 17, 2017
@bvaughn bvaughn deleted the error-boundaries branch July 17, 2017 21:38
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.

2 participants