add componentDidCatch document and link

This commit is contained in:
thomasyimgit
2017-10-11 16:00:33 -04:00
parent 42372b2447
commit 98386b633a

View File

@@ -62,6 +62,12 @@ This method is called when a component is being removed from the DOM:
- [`componentWillUnmount()`](#componentwillunmount)
#### Error Handling
This method is called when there is an error during rendering, in a lifecycle method, or in the constructor of any child component.
- [`componentDidCatch()`](#componentdidcatch)
### Other APIs
Each component also provides some other APIs:
@@ -250,6 +256,24 @@ componentWillUnmount()
* * *
### `componentDidCatch()`
```javascript
componentDidCatch(error, info)
```
Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed. Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.
A class component becomes an error boundary if it defines this lifecycle method.
For more details, see [*Error Handling in React 16*](/blog/2017/07/26/error-handling-in-react-16.html).
> Note
>
> Error boundaries only catch errors in the components **below** them in the tree. An error boundary cant catch an error within itself.
* * *
### `setState()`
```javascript