File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed
Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -4,21 +4,13 @@ import { withRouter } from 'react-router-dom';
44class LoginForm extends React . Component {
55 constructor ( props ) {
66 super ( props ) ;
7- this . state = {
8- login : '' ,
9- password : ''
10- } ;
11- }
12-
13- handleChange = ( { target } ) => {
14- this . setState ( {
15- [ target . name ] : target . value
16- } ) ;
7+ this . login = React . createRef ( ) ;
8+ this . password = React . createRef ( ) ;
179 }
1810
1911 handleSubmit = ( e ) => {
2012 e . preventDefault ( ) ;
21- if ( this . state . login === 'Admin' && this . state . password === '12345' ) {
13+ if ( this . login . current . value === 'Admin' && this . password . current . value === '12345' ) {
2214 localStorage . setItem ( 'auth' , 'true' ) ;
2315 this . props . history . push ( "/profile" ) ;
2416 }
@@ -32,11 +24,11 @@ class LoginForm extends React.Component {
3224 < form onSubmit = { this . handleSubmit } >
3325 < label >
3426 Login:
35- < input type = "text" name = "login" onChange = { this . handleChange } />
27+ < input type = "text" name = "login" ref = { this . login } />
3628 </ label >
3729 < label >
3830 Password:
39- < input type = "password" name = "password" onChange = { this . handleChange } />
31+ < input type = "password" name = "password" ref = { this . password } />
4032 </ label >
4133 < input type = "submit" value = "Submit" />
4234 </ form >
You can’t perform that action at this time.
0 commit comments