import React, { useState } from "react"; function SimpleForm() { const [formData, setFormData] = useState({ username: "", password: "" }); const handleChange = (e) => { const { name, value } = e.target; setFormData((prevData) => ({ ...prevData, [name]: value })); }; const handleSubmit = (e) => { e.preventDefault(); console.log("Form submitted:", formData); }; return ( <form onSubmit={handleSubmit}> <div> <label>Username:</label> <input type="text" name="username" value={formData.username} onChange={handleChange} /> </div> <div> <label>Password:</label> <input type="password" name="password" value={formData.password} onChange={handleChange} /> </div> <button type="submit">Submit</button> </form> ); } export default SimpleForm;