⊗jsrtPmFmsSI 64 of 112 menu

Working with select in React

Now let's work with drop-down lists select. Working with them is also almost no different from working with inputs and checkboxes.

Let's say we have a select like this:

function App() { return <div> <select> <option>text1</option> <option>text2</option> <option>text3</option> <option>text4</option> </select> </div>; }

Let's make it work using React:

function App() { const [value, setValue] = useState(''); function handleChange(event) { setValue(event.target.value); } return <div> <select value={value} onChange={handleChange}> <option>text1</option> <option>text2</option> <option>text3</option> <option>text4</option> </select> <p> your choice: {value} </p> </div>; }

Make a drop-down list of cities. Also make a paragraph in which the user's choice will be displayed.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline