Skip to main content
100%

Select with React

✓ Published1🌍 Public
Ffjvoris
Last edited Mar 5, 2023
Created on Mar 5, 2023

This example demonstrates a simple pet-selection dropdown built with React and ReactDOM. It shows how a controlled `<select>` element updates its displayed label when a user chooses a new option from the list of six animals. The App component uses the `useState` hook to track the selected value, passing it down to a reusable Dropdown component that maps over the options array. The dropdown’s `onChange` event triggers `setSelectedValue`, and the selected attribute highlights the current choice, with the initial value set to hamster.

AI-generated description

Half way towards a smiley face.

MIT Licensed

Similar vizzes