Skip to content

Commit b05d90e

Browse files
Peter Arganyfacebook-github-bot
Peter Argany
authored andcommitted
Remove type union in Picker.js
Summary: Flow type unions don't play well with Fabric components. This diff removes a union in `Picker.js` and fixes all the flow errors. Before this diff, all these surfaces would crash with the new Fabric Picker impl, because the impl asserts that this field is a string. Reviewed By: sammy-SC Differential Revision: D24236317 fbshipit-source-id: 6e646c84fcd16658aaabe5e93507f5f33b346a65
1 parent ccc4f01 commit b05d90e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Libraries/Components/Picker/Picker.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ type PickerItemProps = $ReadOnly<{|
3030

3131
/**
3232
* The value to be passed to picker's `onValueChange` callback when
33-
* this item is selected. Can be a string or an integer.
33+
* this item is selected.
3434
*/
35-
value?: ?(number | string),
35+
value?: ?string,
3636

3737
/**
3838
* Color of this item's text.
@@ -62,9 +62,9 @@ type PickerProps = $ReadOnly<{|
6262
style?: ?TextStyleProp,
6363

6464
/**
65-
* Value matching value of one of the items. Can be a string or an integer.
65+
* Value matching value of one of the items.
6666
*/
67-
selectedValue?: ?(number | string),
67+
selectedValue?: ?string,
6868

6969
/**
7070
* Callback for when an item is selected. This is called with the following parameters:

packages/rn-tester/js/examples/Modal/ModalExample.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ModalExample extends React.Component<{...}, $FlowFixMeState> {
7979
modalVisible: false,
8080
transparent: false,
8181
presentationStyle: 'fullScreen',
82-
selectedSupportedOrientation: 0,
82+
selectedSupportedOrientation: '0',
8383
currentOrientation: 'unknown',
8484
};
8585

@@ -130,7 +130,7 @@ class ModalExample extends React.Component<{...}, $FlowFixMeState> {
130130
onRequestClose={() => this._setModalVisible(false)}
131131
supportedOrientations={
132132
supportedOrientationsPickerValues[
133-
this.state.selectedSupportedOrientation
133+
Number(this.state.selectedSupportedOrientation)
134134
]
135135
}
136136
onOrientationChange={evt =>
@@ -222,12 +222,12 @@ class ModalExample extends React.Component<{...}, $FlowFixMeState> {
222222
this.setState({selectedSupportedOrientation: i})
223223
}
224224
itemStyle={styles.pickerItem}>
225-
<Item label="Portrait" value={0} />
226-
<Item label="Landscape" value={1} />
227-
<Item label="Landscape left" value={2} />
228-
<Item label="Portrait and landscape right" value={3} />
229-
<Item label="Portrait and landscape" value={4} />
230-
<Item label="Default supportedOrientations" value={5} />
225+
<Item label="Portrait" value={'0'} />
226+
<Item label="Landscape" value={'1'} />
227+
<Item label="Landscape left" value={'2'} />
228+
<Item label="Portrait and landscape right" value={'3'} />
229+
<Item label="Portrait and landscape" value={'4'} />
230+
<Item label="Default supportedOrientations" value={'5'} />
231231
</Picker>
232232
</View>
233233
</View>

0 commit comments

Comments
 (0)