form handler
1 step
const [user ,setUser]= useState({
email:"",
password:''
})
// 2 step
<input onChange={handleChange} value={user.email} id="email-address"
name="email" type="email" autocomplete="email" required >
//3 step
<form onSubmit={dataHandler} class="mt-8 space-y-6"
action="#" method="POST">
4 step
function handleChange(evt) {
const value = evt.target.value;
setUser({
...user,
[evt.target.name]: value
});
5 step
const dataHandler = (e)=>{
e.preventDefault()
console.log(user)
}
Comments
Post a Comment