-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4f1945
commit 00236e5
Showing
2 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React,{useState} from 'react'; | ||
|
||
const Register = () => { | ||
|
||
const [info,setInfo] = useState({name:"",email:"",password:"",error:"",loading:false,message:"",showForm:true}); | ||
|
||
const {name,email,password,error,loading,message,showForm} = info | ||
|
||
const handleSubmit=(event)=>{ | ||
event.preventDefault(); | ||
console.table({name,email,password,error,loading,message,showForm}) | ||
} | ||
|
||
const handleChange= name =>(event)=>{ | ||
setInfo({...info,error:false,[name]: e.target.value}); | ||
} | ||
const registerForm=()=>{ | ||
return ( | ||
<form onSubmit={handleSubmit}> | ||
{/* Name */} | ||
<div className="form-group"> | ||
{/* dynamic handle change by passing the value straight to it */} | ||
<input type="text" value={name} className="form-control" onChange={handleChange("name")} placeholder="Enter Your Name"/> | ||
</div> | ||
{/* Email */} | ||
<div className="form-group"> | ||
<input type="email" value={email} className="form-control" onChange={handleChange("email")} placeholder="Enter Your @Email address"/> | ||
</div> | ||
{/* Password */} | ||
<div className="form-group"> | ||
<input type="password" value={password} className="form-control" onChange={handleChange("password")} placeholder="Enter Your password"/> | ||
</div> | ||
<button className="btn btn-info">Register</button> | ||
</form> | ||
) | ||
} | ||
return ( | ||
<> | ||
{registerForm()} | ||
</> | ||
) | ||
} | ||
|
||
export default Register |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters