Please read the guide .
Please answer the question in detail
import React, { useState } from "react"; function App() { const [selectedColor, setSelectedColor] = useState(""); const handleClick = (color) => { setSelectedColor(color); }; return ( <div> <h1>Select a color</h1> <div> <button onClick={() => handleClick("Red")}>Red</button> <button onClick={() => handleClick("Blue")}>Blue</button> <button onClick={() => handleClick("Green")}>Green</button> <button onClick={() => handleClick("Yellow")}>Yellow</button> </div> <p>You have selected the color {selectedColor}.</p> </div> ); } export default App;
Doubtly is an online community for engineering students, offering:
Get the pro version for free by logging in!
5.7k questions
5.1k answers
108 comments
561 users