File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -5,14 +5,13 @@ import { useAuthUser } from '../utils/AuthUser'
5
5
6
6
const Login = ( { history } ) => {
7
7
const { login } = useAuthUser ( )
8
- const [ username , setUsername ] = useState ( '' )
9
- const [ password , setPassword ] = useState ( '' )
10
8
const [ errorMessage , setErrorMessage ] = useState ( )
11
9
12
10
function handleSubmit ( e ) {
13
11
e . preventDefault ( )
12
+ const [ usernameNode , passwordNode ] = e . target . elements
14
13
15
- if ( username === 'react' && password === 'react' ) {
14
+ if ( usernameNode . value === 'react' && passwordNode . value === 'react' ) {
16
15
login ( )
17
16
history . push ( '/projects' )
18
17
} else {
@@ -33,8 +32,8 @@ const Login = ({ history }) => {
33
32
</ p >
34
33
{ errorMessage && < p style = { { color : 'red' } } > { errorMessage } </ p > }
35
34
< form onSubmit = { handleSubmit } className = "spacing" >
36
- < input type = "text" placeholder = "Username" onChange = { e => setUsername ( e . target . value ) } required />
37
- < input type = "password" placeholder = "Password" onChange = { e => setPassword ( e . target . value ) } required />
35
+ < input type = "text" placeholder = "Username" required />
36
+ < input type = "password" placeholder = "Password" required />
38
37
< button type = "submit" className = "button" >
39
38
Login
40
39
</ button >
You can’t perform that action at this time.
0 commit comments