Skip to content

Commit cabae39

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
add nullptr check to avoid crash in RCTScrollViewComponentView (#42156)
Summary: Pull Request resolved: #42156 changelog: [internal] Add a missing nullptr check to prevent crash if called after component was reused Reviewed By: fkgozali Differential Revision: D52572807 fbshipit-source-id: 1b5b26996e562abbcb986865299e02df20b58043
1 parent 016bb24 commit cabae39

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
471471

472472
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView
473473
{
474+
if (!_eventEmitter) {
475+
return;
476+
}
477+
474478
_isUserTriggeredScrolling = NO;
475479
static_cast<const ScrollViewEventEmitter &>(*_eventEmitter).onScrollToTop([self _scrollViewMetrics]);
476480
[self _updateStateWithContentOffset];

0 commit comments

Comments
 (0)