Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Boundary fallback not rendering #3803

Closed
5 of 11 tasks
frozencap opened this issue May 7, 2024 · 1 comment
Closed
5 of 11 tasks

Error Boundary fallback not rendering #3803

frozencap opened this issue May 7, 2024 · 1 comment

Comments

@frozencap
Copy link

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: ~5.22.0

react-native version: 0.74.1 and 0.73.6

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

[Link to issue]

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: "YOUR DSN HERE",
  debug: true, 
});

const App = () => {
  return (
    <Sentry.ErrorBoundary fallback={<p>An error has occurred</p>}>
      <View style={styles.container}>
        <Text>Open up App.tsx to start working on your app!</Text>
        <Button
          title="Test Error Boundary fallback"
          onPress={() => {
            throw new Error("Hello, again, Sentry!");
          }}
        />
      </View>
    </Sentry.ErrorBoundary>
  );
};

I have the following issue:
Error Boundary doesn't render the fallback component

Steps to reproduce:

  • Step 1: click on the button

Actual result:

No Error Boundary fallback is rendered

Expected result:

Error Boundary fallback is rendered

@krystofwoldrich
Copy link
Member

Hi @frozencap,
thank you for the message,

the error boundaries only catch rendering errors. The error from your code snippet happens after the components were rendered. This is expected behaviour. The error from your snipped will cause a crash which will be reported by Sentry. To avid the crash you will have to use try/catch.

The Sentry error boundary is implemented using the React componentDidCatch API https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary

Let us know if this was helpful, if you have any other question feel free to post it here or open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

No branches or pull requests

2 participants