🌍 Public
Viewing a saved revision (read-only)
b4614798b8af40198654c03a6316adfa
Menus with React
This example shows a pet-selection dropdown menu built with React. The interface displays a labeled "Choose a pet" menu with options for dog, cat, hamster, parrot, spider, and goldfish, defaulting to hamster. The code uses React's `useState` hook to track the selected value, and a reusable `Dropdown` component that maps over the options array to render native HTML `<select>` and `<option>` elements. The component updates the state via an `onSelectedValueChange` callback, with `ReactDOM.render` mounting the app into the root div.
AI-generated descriptionMenu example used here
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select