Skip to content

Instantly share code, notes, and snippets.

@cmdcolin
Created April 18, 2024 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmdcolin/c93b18f9a4a3c69f0f905c24e486bbac to your computer and use it in GitHub Desktop.
Save cmdcolin/c93b18f9a4a3c69f0f905c24e486bbac to your computer and use it in GitHub Desktop.
function MySelectBox() {
const opts = ["apple", "banana", "orange"];
const [mySelection, setMySelection] = useState("apple");
return (
<select
value={mySelection}
onChange={event => setMySelection(event.target.value)}
>
{opts.map(o => (
<option key={o} value={o}>
{o}
</option>
))}
</select>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment