You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionwithErrorBoundary(WrappedComponent,errorBoundaryOptions,){constcomponentDisplayName=WrappedComponent.displayName||WrappedComponent.name||UNKNOWN_COMPONENT;constWrapped=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-overhoistNonReactStatics(Wrapped,WrappedComponent);returnWrapped;}
Hello, thanks for your answer.
Unfortunately, I am using @sentry/react-native which has a fixed dependency on @sentry/react@8.55.0.
However I had a look at @sentry/react@9.42.0's dist, and the code looks the same as in 8.55.0, so I assume the behavior would be the same.
Hey @OoDeLally I had a quick look at this. I did not encounter any unexpected re-renders (testing on react 19) – can you specify what you exactly mean with
MyScreenWithFallback does not rerender when props are identical.
LOG {"errorBoundary(NounScreen)": [Function Wrapped]} Re-rendered because the props object itself changed but its values are all equal. This could have been avoided by making the component pure, or by preventing its father from re-rendering. More info at http://bit.ly/wdyr02
LOG prev props: {"caseId": "Nominative"} !== {"caseId": "Nominative"} :next props
With React.memo.(...)
// No logs
The version with the memo() is noticeably faster when switching screens.
Activity
linear commentedon Jul 28, 2025
JS-779 withErrorBoundary create unnecessary rerenders
chargome commentedon Jul 28, 2025
Hey @OoDeLally would you mind upgrading the SDK to the latest version and check if the issue persists?
OoDeLally commentedon Jul 28, 2025
Hello, thanks for your answer.
Unfortunately, I am using
@sentry/react-nativewhich has a fixed dependency on@sentry/react@8.55.0.However I had a look at
@sentry/react@9.42.0's dist, and the code looks the same as in8.55.0, so I assume the behavior would be the same.chargome commentedon Jul 28, 2025
@OoDeLally thanks for investigating – I'll have a look!
chargome commentedon Jul 28, 2025
Hey @OoDeLally I had a quick look at this. I did not encounter any unexpected re-renders (testing on react 19) – can you specify what you exactly mean with
Which props are you referring to?
OoDeLally commentedon Jul 29, 2025
I use why-did-you-render to monitor rerenderings:
Without
React.memo(...)With
React.memo.(...)The version with the
memo()is noticeably faster when switching screens.github-actions commentedon Jul 31, 2025
A PR closing this issue has just been released 🚀
This issue was referenced by PR #17230, which was included in the 10.0.0 release.