1.0.5 • Published 5 years ago

react-native-picker-box v1.0.5

Weekly downloads
48
License
MIT
Repository
github
Last release
5 years ago

Table of contents

Installation

Just add react-native-picker-box to your project:

yarn add react-native-picker-box

Basic example

ANDROIDIOS
Basic example gif androidBasic example gif ios

Import

import PickerBox from 'react-native-picker-box';

Using a react-native-picker-box

export default class App extends Component {

  state={
    data: [
      {label: 'Português', value: 'pt'},
      {label: 'Deutsch', value: 'de'},
      {label: 'English', value: 'en'}
    ],
    selectedValue: ''
  }

  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome} onPress={() => this.myref.openPicker() }>Press to select language</Text>
        <Text style={styles.instructions}>{ this.state.selectedValue }</Text>
        <PickerBox
          ref={ref => this.myref = ref}
          data={ this.state.data }
          onValueChange={value => this.setState({ selectedValue: value })}
          selectedValue={ this.state.selectedValue }
        />
      </View>
    );
  }
}

Props

NameTypeDefaultRequiredDescription
dataarraynoneYesEach item should be in the following format: {label: 'JavaScript', value: 'js'}
onValueChangefunctionnullYesCallback for when an item is selected. This is called with the following parameter: value
selectedValuestringnoneNoValue matching value of one of the items. Can be a string or an integer.
maxHeightnumber-NoCustom maxHeight. Is the maximum height for this component.
statusbarbooleantrueNoStatusBar overlapping.
itemTextColorstring#757379NoCustom item text color.
separatorColorstring#757379NoCustom separator color.
prevTextColorstring#572580NoCustom button(prev) text color.
prevTextLabelstringCancelNoCustom button(prev) text label.

Methods

Method NameArgumentsDescription
openPickernullOpen picker. Use refs for open Picker following the example

Thanks for being interested on making this package better.

git clone https://github.com/duhwcarvalho/react-native-picker-box.git
cd react-native-picker-box
react-native upgrade
yarn
react-native run-android or react-native run-ios

Author

@duhwcarvalho