🌍 Public
Viewing a saved revision (read-only)
cc7d67eb7ead4d90ac66bd107eff6bb7
Menus with React
This example shows how to build interactive dropdown menus using React’s `useState` hook to manage selected values. It renders a labeled `<select>` element with four car options (Volvo, Saab, Mercedes, Audi) and updates the displayed choice when the user changes the selection. The code imports `createRoot` from `react-dom` and defines a reusable `Dropdown` component that receives `options`, `selectedValue`, and `onSelectedValueChange` callbacks. React 18.2.0 loads from a CDN, with styling applied through plain CSS in the HTML file.
AI-generated descriptionReact Starter code.