S
S
Sergey Suntsev2018-11-26 15:50:33
JavaScript
Sergey Suntsev, 2018-11-26 15:50:33

How to properly catch errors in react 16.x?

I made a container according to the manual . Wrapped them with the main common components. and now if an error is found in some component, then I display the appropriate message.
In the application, a structure in which some components are located inside others and I wrapped everything in <ErrorBoundary>...</ErrorBoundary>
And I want that if an error is found in a child component, then the error was rendered instead of it, and not instead of the parent component itself, which is wrapped in <ErrorBoundary>...</ErrorBoundary>
Interesting, in In general, can there be a manual somewhere about the emergence of errors in React?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-11-26
@GreyCrew

Wrap the child component that might throw an error in an ErrorBoundary. There is no special mechanism for raising errors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question