Skip to content

Instantly share code, notes, and snippets.

@jogilvyt
Created April 19, 2021 14:42
Show Gist options
  • Save jogilvyt/f10e6e387c61a8a7b942d7c1ae6d2312 to your computer and use it in GitHub Desktop.
Save jogilvyt/f10e6e387c61a8a7b942d7c1ae6d2312 to your computer and use it in GitHub Desktop.
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