import { useState } from "react"; function App() { const [name, setName] = useState(""); // Stores name input const [email, setEmail] = useState(""); // Stores email input function handleSubmit(event) { event.preventDefault(); // Prevents page reload alert(`Name: ${name}\nEmail: ${email}`); // Clear the inputs after submitting setName(""); setEmail(""); } return (

Simple Form

setName(event.target.value)} placeholder="Enter your name" style={{ display: "block", margin: "10px auto", padding: "8px" }} /> setEmail(event.target.value)} placeholder="Enter your email" style={{ display: "block", margin: "10px auto", padding: "8px" }} />
); } export default App;