forked from hollygirouard/convert-class-to-hook
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathClassBasedForm.js
60 lines (57 loc) · 1.52 KB
/
ClassBasedForm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React from 'react'
import {
Form, FormGroup, Input,
Label, Col, Button,
} from 'reactstrap'
export default class ClassBasedForm extends React.Component {
constructor(props) {
super(props)
this.state = {
email: '',
password: '',
}
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit(e) {
e.preventDefault();
console.log(this.state);
}
render() {
return (
<Form onSubmit={ this.handleSubmit }>
<h1>Class-Based Form</h1>
<FormGroup row>
<Label for="exampleEmail" sm={ 2 }>Email</Label>
<Col sm={ 8 }>
<Input
type="email"
name="email"
id="exampleEmail"
placeholder="email"
value={ this.state.email }
onChange={ (event) => this.setState({ email: event.target.value }) }
/>
</Col>
</FormGroup>
<FormGroup row>
<Label for="examplePassword" sm={ 2 }>Password</Label>
<Col sm={ 8 }>
<Input
type="password"
name="password"
id="examplePassword"
placeholder="password"
value={ this.state.password }
onChange={ (event) => this.setState({ password: event.target.value })}
/>
</Col>
</FormGroup>
<FormGroup check row>
<Col sm={ { size: 10, offset: 8 } }>
<Button>Submit</Button>
</Col>
</FormGroup>
</Form>
)
}
};