Skip to content

Commit 1a1a798

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
Fix null crash when using maintainVisibleContentPosition on Android (#38891)
Summary: `mFirstVisibleView` is a weak ref so it can also be null when dereferencing. This was reported on the original PR here #35049 (comment) ## Changelog: [ANDROID] [FIXED] - Fix null crash when using maintainVisibleContentPosition on Android Pull Request resolved: #38891 Test Plan: Not sure exactly in what cases this can happen, but the fix is trivial and makes sense. Reviewed By: cortinico Differential Revision: D48192154 Pulled By: rshest fbshipit-source-id: 57a38a22a0e216a33603438355bde0013c014fbf
1 parent ad18f81 commit 1a1a798

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ private void updateScrollPositionInternal() {
103103
}
104104

105105
View firstVisibleView = mFirstVisibleView.get();
106+
if (firstVisibleView == null) {
107+
return;
108+
}
109+
106110
Rect newFrame = new Rect();
107111
firstVisibleView.getHitRect(newFrame);
108112

0 commit comments

Comments
 (0)