Skip to content

Commit d238da7

Browse files
makovkastarfacebook-github-bot
authored andcommitted
Do not crash when ScrollView snapToOffsets is empty
Summary: The value of the `ScrollView.snapToOffsets` property can be an empty array (most likely an issue in the product code), which will crash the app. This diff adds a check to prevent crashing in this scenario and falling back to the default snap behaviour. Changelog: [Android][Fixed] - Do not crash when ScrollView snapToOffsets is empty Reviewed By: sammy-SC Differential Revision: D24502365 fbshipit-source-id: c63b8e3b8f2fb323ebd6c962ee628015934d8e11
1 parent 6eed1e4 commit d238da7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ private void flingAndSnap(int velocityX) {
817817
}
818818

819819
// get the nearest snap points to the target offset
820-
if (mSnapOffsets != null) {
820+
if (mSnapOffsets != null && !mSnapOffsets.isEmpty()) {
821821
firstOffset = mSnapOffsets.get(0);
822822
lastOffset = mSnapOffsets.get(mSnapOffsets.size() - 1);
823823

0 commit comments

Comments
 (0)