File size: 690 Bytes
84c1942 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import React, { ChangeEvent, FunctionComponent } from 'react';
import { Select } from '@codesandbox/components';
type Props = {
mapName?: (param: string) => string;
options: string[];
setValue: (value: string) => void;
value: string;
};
export const PreferenceDropdown: FunctionComponent<Props> = ({
mapName,
options,
setValue,
value,
}) => {
const handleChange = ({ target }: ChangeEvent<any>) => {
setValue(target.value);
};
return (
<Select onChange={handleChange} value={value}>
{options.map(option => (
<option key={option} value={option}>
{mapName ? mapName(option) : option}
</option>
))}
</Select>
);
};
|