question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I cant see the component boundary

See original GitHub issue

Hi, I cant see the boundary component when I throw an error.

the throw error: throw new Error('💥 CABOOM 💥'); trigged by onPress

and the only error that show was the react-native error screen. I was click in dismiss, but the error boundary component not show.

https://user-images.githubusercontent.com/30187750/103559676-6e7e9e80-4eae-11eb-9b64-eb3ad1bdc0cf.mov

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
carloscuestacommented, Jan 5, 2021

No problem, a pleasure to explain. Thanks to you aswell for creating the demo repository ❤️

Have a great day!

1reaction
carloscuestacommented, Jan 5, 2021

Hey @DwCleb

I cant use the state to show the error component, this is not flow in development.

You don’t need state to show the ErrorBoundary component. What happens is that on development mode some errors are catched by the LogBox component -> https://reactnative.dev/blog/2020/07/06/version-0.63#logbox

This component is made for catching unhandled errors on release mode. Not for displaying errors on development. You can read more about this in here: https://carloscuesta.me/blog/managing-react-native-crashes-with-error-boundaries

So you won’t able to render the ErrorBoundary component on Development just by throwing an error from the Button. Because those type of errors are getting caught by the LogBox component on development. As taken out from react-native docs: https://reactnative.dev/docs/debugging#logbox

On release mode, it will work because the LogBox it’s not shipped to your application, so the component will catch all the JavaScript errors just by using the ErrorBoundary component.

The goal is catch JS error, and with State I’m forced a component error show, it’s a controlled situation, not a real situation of error. Using state worked, but this not a real case.

As you say, you’re simulating an error so that clearly it’s not a real case. You’re trying to force an error to render the ErrorBoundary component on development. If you want to render the ErrorBoundary, using the throw Error, use react-native run-ios --variant=release to set the application on release mode, and avoid the LogBox component.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Boundaries - React
Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI ......
Read more >
React Error Boundaries not working with React - Stack Overflow
For checking your ErrorBoundary , throw an error from a reachable section in the component tree which is not: Event handlers; Asynchronous code...
Read more >
Component error handling in React using Error Boundaries
Upgrade React, wrap your component tree with the boundary and start drilling down to find where errors are happening in your existing code...
Read more >
What you may not know about the Error Boundary
Use componentDidCatch() to log error information. Look at these lines, if there is an error then we return the fallback component, else return ......
Read more >
Error Boundaries in React 16 - Rollbar
Error boundaries are React components that catch JavaScript errors anywhere in their child component tree. They can log errors and display a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found