Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

React SPA example #46

Copy link
Copy link
@TomRadford

Description

@TomRadford
Issue body actions

Would be awesome to have an example for a React SPA (ie: no metaframework/ssr) to document the usage of Sentry.reactErrorHandler as per https://docs.sentry.io/platforms/javascript/guides/react/#step-3-capture-react-errors

For this example in particular, would be keen to see how you recommend logging caught and recoverable errors in dev, since the example link above seems to obfuscate these errors, ie is this appropriate or would it re-log errors?

  onUncaughtError: Sentry.reactErrorHandler((error, errorInfo) => {
    console.warn("Uncaught error", error, errorInfo.componentStack);
  }),
  // Callback called when React catches an error in an ErrorBoundary.
  onCaughtError: Sentry.reactErrorHandler((error, errorInfo) => {
    // this is not in above guide
    console.warn("Caught error", error, errorInfo.componentStack);
  }),
  // Callback called when React automatically recovers from errors.
  onRecoverableError: Sentry.reactErrorHandler((error, errorInfo) => {
    // this is not in above guide
    console.warn("Recoverable error", error, errorInfo.componentStack);
  }),

The current react-router example assumes that you're in framework-mode:
https://github.com/getsentry/sentry-javascript-examples/tree/main/apps/react-router
which doesnt seem to be applicable for a SPA?

Keen to clear this up, thanks!

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.