- React will display a page that reports the errors and stacks in development mode when catch error.

- I take a try to redefine UI of that page with
componentDidCatchmethod of anerror boundary component. But it's not as expected.- My UI will be shown for a very short time, then React default UI will covered my page.
- React default UI is implemented in a
<iframe>tag, which hasfixedposition and big-valuez-index. - I have to click the 'x' button, close the React default UI, and let my UI appear.
Is there some methods helping me forbid React default UI in development mode ?
Is there some methods helping me redefine the React default UI in development mode ?
Thanks a lot.
A class component becomes an error boundary if it defines either (or both) of the lifecycle methods
static getDerivedStateFromError()orcomponentDidCatch(). Use staticgetDerivedStateFromError()to render a fallback UI after an error has been thrown. UsecomponentDidCatch()to log error information.Then you can use it as a regular component:
Error boundaries work like a JavaScript
catch {}block, but for components. Only class components can be error boundaries. In practice, most of the time you’ll want to declare an error boundary component once and use it throughout your application.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 the
catch {}block works in JavaScript.