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

Support React 19 #11798

Closed
3 tasks done
AbhiPrasad opened this issue Apr 25, 2024 · 2 comments
Closed
3 tasks done

Support React 19 #11798

AbhiPrasad opened this issue Apr 25, 2024 · 2 comments
Assignees
Labels
Package: react Issues related to the Sentry React SDK

Comments

@AbhiPrasad
Copy link
Member

AbhiPrasad commented Apr 25, 2024

https://react.dev/blog/2024/04/25/react-19

Big thing for us is https://react.dev/reference/react-dom/client/createRoot#parameters

image

Key thing for us is that we can stop recommending Sentry.ErrorBoundary, and instead tell people to use the hooks in react directly!

Tasks

  1. AbhiPrasad
  2. AbhiPrasad
@AbhiPrasad AbhiPrasad added the Package: react Issues related to the Sentry React SDK label Apr 25, 2024
@AbhiPrasad AbhiPrasad assigned AbhiPrasad and unassigned AbhiPrasad Apr 25, 2024
@AbhiPrasad AbhiPrasad self-assigned this May 21, 2024
@AbhiPrasad
Copy link
Member Author

AbhiPrasad commented May 22, 2024

@rickhanlonii The API we're looking to implement for Sentry error monitoring is:

import { reactErrorHandler } from '@sentry/react';
import { hydrateRoot } from "react-dom/client";

ReactDOM.hydrateRoot(
  document.getElementById("root") as HTMLElement,
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  {
    onUncaughtError: Sentry.reactErrorHandler(),
    onCaughtError: Sentry.reactErrorHandler((error, errorInfo) => {
      // optional callback if users want more/custom config in addition?
    }),
  }
);

The only thing here is that if you set a onUncaughtError option, it overrides the default, which means you lose out on the dev mode logging:

https://github.com/facebook/react/blob/3ac551e855f9bec3161da2fc8787958aa62113db/packages/react-reconciler/src/ReactFiberErrorLogger.js#L36-L51

In this case there is no way for us to replicate the An error occurred in the <${componentName}> component: message (because componentName is private API), so asking users to add Sentry.reactErrorHandler degrades their local development experience.

I guess we can tell users to only set this for production, but Sentry can also be used in development environments via Spotlight (Sentry for Development).

Is there a way we can get access to the original onUncaughtError handler so we can execute that, while sending the error to Sentry at the same time?

@AbhiPrasad
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: react Issues related to the Sentry React SDK
Projects
None yet
Development

No branches or pull requests

1 participant