Skip to content

Docs for Error Boundaries #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 7, 2017
Merged

Conversation

krizzu
Copy link

@krizzu krizzu commented Oct 6, 2017

Hey,

Moved this PR here, as said :)

@reactjs-bot
Copy link

reactjs-bot commented Oct 6, 2017

Deploy preview ready!

Built with commit 03dae5b

https://deploy-preview-31--reactjs.netlify.com

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks for the contribution!

Couple of minor tweaks requested.

showButton();
} catch (error) {
// ...
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: You can get rid of this indentation

Copy link
Contributor

Choose a reason for hiding this comment

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

Bump this nit ^

However, React components are declarative and specify *what* should be rendered:

```js
<Button />
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Ditto about indentation.


React 16 prints all errors that occurred during rendering to the console in development, even if the application accidentally swallows them. In addition to the error message and the JavaScript stack, it also provides component stack traces. Now you can see where exactly in the component tree the failure has happened:

<img src="../images/docs/error-boundaries-error-log.png" style="max-width:100%" alt="Error caught by Error Boundary component">
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be nice to share these images between the blog post and the docs page, since they're the same. Maybe git mv the images into images/docs and then update the blog markdown to reference them there?


Note that **error boundaries only catch errors in the components below them in the tree**. An error boundary can’t catch an error within itself. If an error boundary fails trying to render the error message, the error will propagate to the closest error boundary above it. This, too, is similar to how catch {} block works in JavaScript.

#### componentDidCatch Parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think this should be an <h3> (eg ###) rather than <h4>

@krizzu krizzu force-pushed the docs/Error-Boundaries branch from 06b220b to 96e65ae Compare October 6, 2017 21:44
@krizzu
Copy link
Author

krizzu commented Oct 6, 2017

Thanks @bvaughn
Made changes according to your feedback.

@bvaughn
Copy link
Contributor

bvaughn commented Oct 6, 2017

Oooh, one more thing! We require contributors to sign our Contributor License Agreement, and I don't think we have you on file.

In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

(Sorry for the awkwardness here. I'm still getting the new repo setup. Normally this comment is automated.)

@krizzu
Copy link
Author

krizzu commented Oct 6, 2017

No worries, I've already signed it :)

@bvaughn
Copy link
Contributor

bvaughn commented Oct 7, 2017

Great 😄 Thanks for confirming. Just need to fix the tiny indentation issue and this looks good to go!

@krizzu krizzu force-pushed the docs/Error-Boundaries branch from 96e65ae to 03dae5b Compare October 7, 2017 11:04
@krizzu
Copy link
Author

krizzu commented Oct 7, 2017

@bvaughn
Hey, sorry, I though I did those intends, but apparently not. It's all ready now :)

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

No worries. Thanks!

@bvaughn bvaughn merged commit fd4eda8 into reactjs:master Oct 7, 2017
@krizzu krizzu deleted the docs/Error-Boundaries branch October 7, 2017 16:29
jhonmike pushed a commit to jhonmike/reactjs.org that referenced this pull request Jul 1, 2020
* translate React API Reference

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

Co-Authored-By: renato-bohler <renato.bohler@gmail.com>

* Update content/docs/reference-react.md

* Update content/docs/reference-react.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants