concept PickerIOS in category react native

appears as: PickerIOS, PickerIOS
React Native in Action

This is an excerpt from Manning's book React Native in Action.

Using PickerIOS, you can access the native iOS Picker component. This component basically allows you to scroll through and choose from a list of values using the native UI (see figure 10.3). PickerIOS has the methods and props listed in table 10.2.

Table 10.2 PickerIOS methods and props
Prop Type Description
itemStyle Object (style) The text style for items within the container
onValueChange Function (value) Called when the PickerIOS value changes
selectedValue Number or string Currently selected PickerIOS value

Figure 10.3 PickerIOS rendering a list of people

c10_03.tif

PickerIOS wraps a list of items to be rendered as children. Each child item must be a PickerIOS.Item:

Listing 10.8 Using PickerIOS with an array of PickerIOS.Items
const people = [   #an array of people ];

render() {
  <PickerIOS>
    {
      people.map((p, i) =>(
        <PickerItem key={i} value={p} label={p}/>
      ))
    }
  <PickerIOS>