Dropdown in React — React Technical Interview Questions & Answers
Dropdown in React
Dropdown in React
- Controlled <select value={city} onChange={e => setCity(e.target.value)}> with <option> children. Same idea as an input. Custom dropdowns (div + keyboard) are extra a11y work — native select is the viva answer unless they ask for a design-system menu.
- Dropdown in React — start Pune. Pick Delhi → state Delhi. Uncontrolled select is harder to test.
Technical Interview Tip: Controlled <select>.
Code Examples for Dropdown in React
Example
// Select
import { useState } from "react";
export default function City() {
const [city, setCity] = useState("Pune");
return (
<select value={city} onChange={(e) => setCity(e.target.value)}>
<option>Pune</option>
<option>Delhi</option>
</select>
);
}
Dropdown in React — start Pune. Pick Delhi → state Delhi. Uncontrolled select is harder to test.
How to Explain Dropdown in React to an Interviewer
Explain Dropdown as if you are teaching a junior — definition, then one tiny UI.
Controlled select. Value + onChange.
Write 5–10 lines that use Dropdown and say what the UI does.
Show JSX Say the screen
What mistake do freshers make with Dropdown?
Native first.