update select to use destructuring
This commit is contained in:
@ -9,12 +9,12 @@ Use the `values` array to pass an array of `[value, text]` elements and the `sel
|
|||||||
```jsx
|
```jsx
|
||||||
function Select ({ values, callback, disabled = false, readonly = false, selected }) {
|
function Select ({ values, callback, disabled = false, readonly = false, selected }) {
|
||||||
return (
|
return (
|
||||||
<select
|
<select
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
readOnly={readonly}
|
readOnly={readonly}
|
||||||
onChange={(event) => callback(event.target.value)}
|
onChange={({ target : { value }}) => callback(value)}
|
||||||
>
|
>
|
||||||
{values.map(v => <option selected={selected === v[0]}value={v[0]}>{v[1]}</option>)}
|
{values.map(([value, text]) => <option selected={selected === value}value={value}>{text}</option>)}
|
||||||
</select>
|
</select>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user