Minor bug in random generator for `selection` prop

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 https://github.com/facebook/react-native/pull/16871

Differential Revision: D6371550

Pulled By: shergin

fbshipit-source-id: 84866d1eb02c2be51cd15a60490604d28fa18973
This commit is contained in:
Eric Rozell 2017-11-19 17:09:53 -08:00 committed by Facebook Github Bot
parent 6b26971a56
commit 766f020e68
1 changed files with 1 additions and 1 deletions

View File

@ -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);
}