Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 1.39 KB

readme.md

File metadata and controls

58 lines (44 loc) · 1.39 KB

react-native-picker-scrollview

a pure js picker, each option item customizable

/*******

needed a fork, because despite the component is a clever solution, it was not really maintained anymore, and had some conflicts with the new react version. also it is nice to customize it a bit on our own, so we can have a nice solution.

*******/

example

usage

npm install @gronda-team/react-native-picker-scrollview --save
import React, {Component} from 'react';
import ScrollPicker from '@gronda-team/react-native-picker-scrollview';

export default class SimpleExample extends Component {

    render() {
        return(
            <ScrollPicker
                ref={(sp) => {this.sp = sp}}

                dataSource={[
                    'a',
                    'b',
                    'c',
                    'd',
                ]}
                selectedIndex={0}
                itemHeight={50}
                wrapperHeight={250}
                highlightColor={'#d8d8d8'}
                renderItem={(data, index, isSelected) => {
                    //
                }}
                onValueChange={(data, selectedIndex) => {
                    //
                }}
            />
        )
    }


    //
    someOtherFunc(){
        this.sp.scrollToIndex(2);   // select 'c'
        let selectedValue = this.sp.getSelected();  // returns 'c'
    }
}