Files
reacord/playground/fruit-select.tsx
2021-12-28 22:33:35 -06:00

32 lines
706 B
TypeScript

import React, { useState } from "react"
import { Button, Option, Select } from "../library/main"
export function FruitSelect() {
const [value, setValue] = useState<string>()
const [finalChoice, setFinalChoice] = useState<string>()
if (finalChoice) {
return <>you chose {finalChoice}</>
}
return (
<>
{"_ _"}
<Select
placeholder="choose a fruit"
value={value}
onChangeValue={setValue}
>
<Option value="🍎" />
<Option value="🍌" />
<Option value="🍒" />
</Select>
<Button
label="confirm"
disabled={value == undefined}
onClick={() => setFinalChoice(value)}
/>
</>
)
}