-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react
SDK Version
8.55.0
Framework Version
8.55.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
export const MyScreenWithFallback = Sentry.withErrorBoundary(MyScreen, {
fallback: FatalErrorFallback,
});
Steps to Reproduce
- Run this with dummy components
Expected Result
MyScreenWithFallback
does not rerender when props are identical.
Actual Result
MyScreenWithFallback
rerenders everytime.
Workaround
export const MyScreenWithFallback = React.memo(Sentry.withErrorBoundary(MyScreen, {
fallback: FatalErrorFallback,
}));
Real solution
function withErrorBoundary(
WrappedComponent,
errorBoundaryOptions,
) {
const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;
const Wrapped = React.memo(((props) => React.createElement(ErrorBoundary, { ...errorBoundaryOptions,}
, React.createElement(WrappedComponent, { ...props,} )
)
));
Wrapped.displayName = `errorBoundary(${componentDisplayName})`;
// Copy over static methods from Wrapped component to Profiler HOC
// See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over
hoistNonReactStatics(Wrapped, WrappedComponent);
return Wrapped;
}
Metadata
Metadata
Assignees
Type
Projects
Status
Waiting for: Product Owner