mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6eed1e4f80
commit
d238da71aa
+1
-1
@@ -817,7 +817,7 @@ public class ReactHorizontalScrollView extends HorizontalScrollView
|
||||
}
|
||||
|
||||
// get the nearest snap points to the target offset
|
||||
if (mSnapOffsets != null) {
|
||||
if (mSnapOffsets != null && !mSnapOffsets.isEmpty()) {
|
||||
firstOffset = mSnapOffsets.get(0);
|
||||
lastOffset = mSnapOffsets.get(mSnapOffsets.size() - 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user