Cero-Studio / ReactNativeWheelPicker

Other
381 stars 239 forks source link

How to get the values instead of the position? #124

Open marcovignotto opened 4 years ago

marcovignotto commented 4 years ago

I think your plugin is great! But how to get the values instead of the position? Example:

const wheelPickerData = ['3', '4', '5', '6', '7', '10'];

const MyPicker = props => {
  const [state, setState] = useState();

  const onItemSelected = item => {
    setState(item);
    console.log(item);
  };

  return (
    <View>
      <WheelPicker
        // selectedItem={this.state.selectedItem}
        data={wheelPickerData}
        onItemSelected={onItemSelected}
      />
    </View>
  );
};

with this I just get the position of the wheel but not the value of the selection How to? Thanks!

hungtrn75 commented 4 years ago

value = wheelPickerData[state]