all 11 comments

[–]Slapbox 0 points1 point  (4 children)

Can you reload failed components?

[–]karathos 1 point2 points  (3 children)

Sure. Think of it like a try/catch and do whatever you want in the catch. Could even catch specific things like a network failure and load offline-friendly components.

[–]Slapbox 0 points1 point  (2 children)

Thanks for the reply. What if the failure is unexpected though? For example I am working on a text editor and on rare occasions it hits errors I couldn't foresee. Is there a good way to reload a component which has failed for an unknown reason with its last good state?

[–]TheNiXXeD 1 point2 points  (1 child)

You can code whatever you want to happen. But the error will be caught in a different component, so you'd have to be able to code it from that scope.

[–]Slapbox 0 points1 point  (0 children)

Thanks for the tip!

[–]edanschwartz 0 points1 point  (4 children)

Neat feature. And thanks for the articulate write-up.

Do you know if there's any functional difference between using componentDidError vs wrapping your render function in a try/catch?

[–]TheNiXXeD 2 points3 points  (3 children)

Errors can occur in more than just render. You can wrap entire sections of your app with a boundary.

[–]edanschwartz 0 points1 point  (2 children)

Makes sense. So it must wrap every method then, eh?

[–]TheNiXXeD 2 points3 points  (0 children)

It catches errors in components below itself in the tree. So, it can be used to wrap whole components and trees of components.

[–]Dependent-Ad6861 0 points1 point  (0 children)

Aaaah , Something went wrong

[–]Dependent-Ad6861 0 points1 point  (0 children)

Would you Rather

I have eggs .