Skip to content

Commit

Permalink
Fix crash on empty snapToOffsets prop to ScrollView
Browse files Browse the repository at this point in the history
Summary:
When the `snapToOffsets` prop is empty array, the scroll view would crash unexpectly. This diff fixed that by treating empty array prop as null value for `snapToOffsets`.

Changelog:
[Android][Fixed] - Fix crash on empty snapToOffsets array

Reviewed By: makovkastar

Differential Revision: D34802022

fbshipit-source-id: af330512e444081b0cb02b65288ec5cd2bd14205
  • Loading branch information
ryancat authored and facebook-github-bot committed Mar 14, 2022
1 parent 2f813f8 commit 145fd04
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void setSnapToAlignment(ReactHorizontalScrollView view, String alignment)
@ReactProp(name = "snapToOffsets")
public void setSnapToOffsets(
ReactHorizontalScrollView view, @Nullable ReadableArray snapToOffsets) {
if (snapToOffsets == null) {
if (snapToOffsets == null || snapToOffsets.size() == 0) {
view.setSnapOffsets(null);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void setSnapToInterval(ReactScrollView view, float snapToInterval) {

@ReactProp(name = "snapToOffsets")
public void setSnapToOffsets(ReactScrollView view, @Nullable ReadableArray snapToOffsets) {
if (snapToOffsets == null) {
if (snapToOffsets == null || snapToOffsets.size() == 0) {
view.setSnapOffsets(null);
return;
}
Expand Down

0 comments on commit 145fd04

Please sign in to comment.