mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
docs: document prod vs dev behavior difference in componentDidCatch (#2168)
This commit is contained in:
@@ -413,6 +413,12 @@ class ErrorBoundary extends React.Component {
|
||||
}
|
||||
```
|
||||
|
||||
Production and development builds of React slightly differ in the way `componentDidCatch()` handles errors.
|
||||
|
||||
On development, the errors will bubble up to `window`, this means that any `window.onerror` or `window.addEventListener('error', callback)` will intercept the errors that have been caught by `componentDidCatch()`.
|
||||
|
||||
On production, instead, the errors will not bubble up, which means any ancestor error handler will only receive errors not explictly caught by `componentDidCatch()`.
|
||||
|
||||
> Note
|
||||
>
|
||||
> In the event of an error, you can render a fallback UI with `componentDidCatch()` by calling `setState`, but this will be deprecated in a future release.
|
||||
|
||||
Reference in New Issue
Block a user