Error Boundary in React: why does 'throw new Error('some message')' fail and 'throw errorObj' work?

前端 未结 1 1030
甜味超标
甜味超标 2021-02-09 10:45

I\'m learning Error Boundaries in React. I think I\'ve got a good basic understanding but am having trouble implementing them for asynchronous processes, such as loading data.

1条回答
  •  醉话见心
    2021-02-09 10:49

    This is an artifact of the dev environment. You can see your actual UI by hitting "escape" or the "X" to dismiss the stack trace. This won't show up in production. I believe the react dev code looks at where the Exception was thrown and if it's in your code then you see the UI.

    See: React still showing errors after catching with ErrorBoundary

    0 讨论(0)
提交回复
热议问题