Created
May 13, 2021 05:14
-
-
Save adarshaacharya/fc44ddadda3e9a25124bda3f5a2fea54 to your computer and use it in GitHub Desktop.
Handle large form in react in easy way
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'; | |
export const LoggedOutRouter = () => { | |
const [values, setValues] = useState({ | |
email: '', | |
password: '', | |
}); | |
const handleSubmit = (e: any) => { | |
e.preventDefault(); | |
isLoggedInVar(true); // updating reactive var | |
}; | |
const handleChange = (e: any) => | |
setValues({ ...values, [e.target.name]: e.target.value }); | |
return ( | |
<div> | |
<h1>LOGIN PAGE</h1> | |
<form onSubmit={handleSubmit}> | |
<input | |
type="email" | |
name="email" | |
id="email" | |
value={values.email} | |
onChange={handleChange} | |
/> | |
<input | |
type="password" | |
name="password" | |
id="password" | |
value={values.password} | |
onChange={handleChange} | |
/> | |
<button type="submit">Log In</button> | |
</form> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment