Answer the question
In order to leave comments, you need to log in
Difference between React Context and ErrorBoundary?
I would like to know what will be the fundamental difference between:
1. The class hoc ErrorBoundary, which catches errors in child components
2. The functional hoc as a provider, which has its own error state, where the child components are passed the state and the function for changing this state
Written using the first option, but I thought about it, but what will actually be the main difference? I noticed for myself that the functional hoc through the context can:
1. Call the function anywhere in the code, while the ErrorBoundary will not catch the error in some cases (for example, when clicking on the throw new Error() button, it will not work, you need prescribe a change in the local state)
2. Clean console (a strange and modest plus, but still)
So I want to know if ErrorBoundary provides some other functionality? Thank you.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question