A cross platform native picker for both iOS and Android.
npm install react-native-pickr
Renders a native picker component for iOS and Android. On iOS, the picker renders within a transparent Modal component fixed at the bottom of the screen. Androind uses the OOB Picker.
yarn add react-native-pickr
{ label: , value: } - itemValue: item that was selected from options
javascript
import React, { Component } from 'react';
import Pickr from 'react-native-pickr';export default class App extends Component {
constructor(props) {
super(props);
this.state = {
selectedUsState: 'NJ',
}
this._onChange = this._onChange.bind(this);
}
_onChange(value) {
this.setState({selectedUsState: value});
}
render() {
return (
options={[{label: 'New Jersey', value: 'NJ'}, {label: 'Pennsylvania', value: 'PA'}, {label: 'West Virginia', value: 'WV'}]}
selectedOption={this.state.selectedUsState}
onChange={this._onChange}
/>
);
}
}
``