import React from "react";
import { Picker as RNPicker } from "react-native";

type Props = {
  onChange?: (value: any) => void;
  options: { label?: string; value: string }[];
  value?: string;
};

const Picker = ({ onChange, options, value }: Props) => (
  <RNPicker onValueChange={onChange} selectedValue={value}>
    {options.map((option) => (
      <RNPicker.Item
        key={option.value}
        label={option.label || option.value}
        value={option.value}
      />
    ))}
  </RNPicker>
);

export default Picker;
