# @nois/react-native-picker-module

> React Native Picker Module Android & IOS

Latest version **1.2.0** (published 2019-07-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nois/react-native-picker-module
pnpm add @nois/react-native-picker-module
yarn add @nois/react-native-picker-module
bun add @nois/react-native-picker-module
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2019-07-15 |
| First published | 2019-07-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 86.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 97 |
| Author | Talut TASGIRAN |
| Maintainers | shawndaonois |
| Keywords | react-native, ios, android, dialog, android spinner, picker, spinner, native |

## Links

- npm: https://www.npmjs.com/package/@nois/react-native-picker-module
- Repository: https://github.com/talut/react-native-picker-module
- Homepage: https://github.com/talut/react-native-picker-module#readme
- Issues: https://github.com/talut/react-native-picker-module/issues
- npm.io page: https://npm.io/package/@nois/react-native-picker-module

## Alternatives

- [react-native-root-siblings](https://npm.io/package/react-native-root-siblings.md) — 102.9K weekly downloads
- [post-robot](https://npm.io/package/post-robot.md) — 93.7K weekly downloads
- [@praxisui/dialog](https://npm.io/package/@praxisui/dialog.md) — 2.0K weekly downloads
- [easy-toggle-state](https://npm.io/package/easy-toggle-state.md) — 350 weekly downloads
- [ngx-lightbox-evp](https://npm.io/package/ngx-lightbox-evp.md) — 19 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2019-07-15
- 1.1.2 — 2019-07-04
- 1.1.1 — 2019-07-04

## README

# React Native Picker Module

With this package you can easily use picker with onPress function.
Also this package is workaround for Android Picker problem (https://github.com/facebook/react-native/issues/15556). 

Using `Modal` and `Picker` component for IOS and using `RecyclerView` and `AlertDialog` for Android as `NativeModule`. 


<img src="./docs/android-picker-module.png"> <img src="./docs/ios-picker-module.png">


### Version 1.1.1

- [https://github.com/talut/react-native-picker-module/issues/7](https://github.com/talut/react-native-picker-module/issues/7) this feature request added.

### Version 1.0.1

- [https://github.com/talut/react-native-picker-module/issues/1](https://github.com/talut/react-native-picker-module/issues/1) this feature request added.
- Typescript definitions added.
- Undefined value props at **IOS** issue solved.

## Getting Started

**With NPM**

```
npm install --save react-native-picker-module
```

**With YARN**

```
yarn add react-native-picker-module
```

**Automatic linking**

```
react-native link react-native-picker-module
```

**Manual Linking**

**[Manual Installation](/docs/manual-installation.md)** (If something went wrong with react-native link)

## Props

| Props       | Type | Default                                          | Required | OS         |
|-------------|------|--------------------------------------------------|----------|------------|
|value        |number|-                                                 |No        |Android, IOS|
|items        |array |-                                                 |**Yes**   |Android, IOS|
|title        |string|-                                                 |No        |Android, IOS|
|ios          |object|`{duration: 330, overlayColor: 'rgba(0,0,0,0.3)'}`|No        |IOS         |
|pickerRef    |func  |-                                                 |**Yes**   |Android, IOS|
|onValueChange|func  |-                                                 |**Yes**   |Android, IOS|
|onCancel     |func  |-                                                 |**No**    |Android, IOS|
|cancelButton |string|`Cancel`                                          |No        |IOS         |
|confirmButton|string|`Confirm`                                         |No        |IOS         |


## Usage

```javascript
import ReactNativePickerModule from 'react-native-picker-module'

state = {
    selectedValue: null,
    data: [
        "Javascript",
        "Go",
        "Java",
        "Kotlin",
        "C++",
        "C#",
        "PHP"
    ]
};

<TouchableOpacity onPress={() => {this.pickerRef.show()}}>
  <Text>Show Language Picker</Text>
</TouchableOpacity>

<ReactNativePickerModule
  pickerRef={e => this.pickerRef = e}
  value={this.state.selectedValue}
  title={"Select a language"}
  items={this.state.data}
  onCancel={()=>{console.log('Cancelled')}}
  onValueChange={(value, index ) => {
  console.log("value: ",value)
  console.log("index: ",index)
    this.setState({
       selectedValue: value,
       selectedIndex: index,
    })
}}/>
```

## FYI
You can use more than one picker in same screen. You just need to set different pickerRef. 
```javascript
this.languagePicker.show();

<ReactNativePickerModule
  pickerRef={e => this.languagePicker = e}
  value={this.state.selectedValue}
  title={"Select a language"}
  items={this.state.data}
  onValueChange={(value,index) => {
        console.log("value: ",value)
        console.log("index: ",index)
    this.setState({
       selectedValue: value,
       selectedIndex: index,
    })
}}/>
```
p.s : If you want to get country list from native device you can use this package: https://github.com/talut/react-native-countries
```javascript
this.countryPicker.show();
<ReactNativePickerModule
  pickerRef={e => this.countryPicker = e}
  value={this.state.selectedValue}
  title={"Select a country"}
  items={this.state.data}
  onValueChange={(value,index) => {
    console.log("value: ",value)
    console.log("index: ",index)
    this.setState({
       selectedValue: value,
       selectedIndex: index,
    })
}}/>
```

## License
This project is licensed under the MIT License - see the LICENSE.md file for details

---
_Source: https://npm.io/package/@nois/react-native-picker-module · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
