DEV Community

Handling Errors in React Components with Error Boundaries

Sarah Chima on February 01, 2018

A React App is usually one big component made up of smaller components. This makes for easy organization of code. A problem arises though when an...
Collapse
 
belhassen07 profile image
Belhassen Chelbi

Everytime you make a to-do app, a bird dies ! haha , so yeah we should use chat, search or what ever in our examples (even though you didn't really make a to do app) , jk
I didn't know we can make an error boundary component, I knew the ComponentDidCatch method but I just used it in a regular component once, as you see I'm a react beginner lol .
Anyway, I liked you article, great as always Sarah :)

Collapse
 
sarah_chima profile image
Sarah Chima

Thank you😊

Collapse
 
manoj016 profile image
Manoj Kumar Maharana

Thank you for posting like such a important blog.

Do you know how to show the full component stack like proper component names in production build?
I am not able to print full stacktrace either, it prints the minified names.

Collapse
 
dustinsoftware profile image
masters.🤔

Thanks for sharing! Error boundaries are one of my favorite React 16 additions. I did not notice the second argument to componentDidCatch, I’ll check it out!

Collapse
 
sarah_chima profile image
Sarah Chima

Yes, you should☺

Collapse
 
avinashlibrary profile image
AvinashLibrary • Edited

I have created proptypes and want to catch the error if the prop type fails.I tried using this method but failed to catch the exception.Can you please help.

New to React started just few days back.