Create React App not showing error message with ErrorBoundary

前端 未结 3 1855
忘掉有多难
忘掉有多难 2021-01-17 10:03

I\'m learning how to use componentDidCatch(). It looks straight forward. It works, but to still show the complete error stack on view.

In separate files

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-17 10:50

    as the document says

    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.

    even when when you use componentDidCatch the error will be logged

    checkout this codepin

提交回复
热议问题