Created
July 12, 2021 10:00
-
-
Save mdtaju/290de89e2662ec51ac8907479c41e4b5 to your computer and use it in GitHub Desktop.
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
import { useState } from 'react'; | |
import './App.css'; | |
function App() { | |
const [Name, setName] = useState('') | |
const [Email, setEmail] = useState('') | |
const [Password, setPassword] = useState('') | |
const SubmitHandler = (event) => { | |
event.preventDefault() | |
event.target.reset() | |
const GetData = { | |
Name, | |
Email, | |
Password | |
// Shortcut, It's mean - Name: Name, Email: Email, Password: Password | |
} | |
console.log(GetData) | |
} | |
return ( | |
<div className="App"> | |
<form onSubmit={(e)=>SubmitHandler(e)}> | |
<h1>Example of getting data from input</h1> | |
<input type="text" placeholder='Your Name' className='FormInput' onBlur={(e) => setName(e.target.value)} required/> | |
<input type="email" placeholder='Your Email' className='FormInput' onBlur={(e) => setEmail(e.target.value)} required/> | |
<input type="password" placeholder='Your Password' className='FormInput' onBlur={(e) => setPassword(e.target.value)} required/> | |
<input type="submit" value="SUBMIT" className='FormSubmit'/> | |
</form> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment