Write a React component that displays the name of a selected option from a hardcoded dropdown menu.
EasyProblem Statement
Write a React component that displays the name of a selected option from a hardcoded dropdown menu.
Sample Input
Options: ['React', 'Angular', 'Vue']
Sample Output
Initially: Selected: React After selection: Selected: [chosen option]
Limits
Time: 2s · Memory: 256 MB
Code Editor
Log in to submit00:00
Try your code in this preview. Submit marks it done.
import React, { useState } from "react"; const Dropdown = () => { const [selected, setSelected] = useState("React"); return ( <div> <select onChange={(e) => { // Update the selected value }}> <option>React</option> <option>Angular</option> <option>Vue</option> </select> <p>Selected: {selected}</p> </div> ); }; export default Dropdown;