Created
April 19, 2021 14:42
-
-
Save jogilvyt/f10e6e387c61a8a7b942d7c1ae6d2312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
import SelectList from "./SelectList"; | |
const options = ["Apples", "Pears", "Lemons", "Limes"]; | |
function App() { | |
const [selectedValue, setSelectedValue] = useState(options[0]); | |
return ( | |
<div className="App"> | |
<SelectList> | |
<SelectList.Toggle>{selectedValue}</SelectList.Toggle> | |
<SelectList.Dropdown> | |
{options.map((option, index) => ( | |
<SelectList.Item | |
key={index} | |
onClick={() => setSelectedValue(option)} | |
> | |
{option} | |
</SelectList.Item> | |
))} | |
</SelectList.Dropdown> | |
</SelectList> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment