Skip to content

Commit

Permalink
Minor bug in random generator for selection prop
Browse files Browse the repository at this point in the history
Summary:
`.sort()` will sort on the string value by default, so if you generate [18, 8], they will stay in that order. Adding comparer to ensure values are sorted numerically.

Found a bug in RNTester.

Ran RNTester and confirmed that bug could be reproduced.

[IOS][BUGFIX][RNTester] - patch test to implement desired behavior.
Closes #16871

Differential Revision: D6371550

Pulled By: shergin

fbshipit-source-id: 84866d1eb02c2be51cd15a60490604d28fa18973
  • Loading branch information
rozele authored and facebook-github-bot committed Nov 20, 2017
1 parent 6b26971 commit 766f020
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion RNTester/js/TextInputExample.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class SelectionExample extends React.Component<$FlowFixMeProps, SelectionExample
}

selectRandom() {
var positions = [this.getRandomPosition(), this.getRandomPosition()].sort();
var positions = [this.getRandomPosition(), this.getRandomPosition()].sort((a, b) => a - b);
this.select(...positions);
}

Expand Down

0 comments on commit 766f020

Please sign in to comment.