Skip to content

Commit e864a56

Browse files
author
Saulo Benigno
committed
finished conversion to functional components
1 parent b71dfea commit e864a56

File tree

3 files changed

+14
-42
lines changed

3 files changed

+14
-42
lines changed

.idea/workspace.xml

+2-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Form.jsx

+8-32
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
11
import React from 'react'
22

3-
export default class Form extends React.Component {
3+
const Form = (props) =>{
44

5-
constructor(props) {
6-
super();
7-
this.state = {
8-
days: 10,
9-
symbol: '',
10-
algo: '',
11-
};
12-
}
13-
14-
callDays(event) {
15-
this.setState({
16-
days: event.target.value
17-
});
18-
19-
this.props.changeDays(event.target.value);
20-
}
21-
22-
render() {
5+
const callDays = (event) => {
6+
props.changeDays(event.target.value);
7+
}
238

249
const callSymbol = (symbol) => {
25-
this.setState({
26-
symbol: symbol,
27-
});
28-
29-
this.props.changeSymbol(symbol);
10+
props.changeSymbol(symbol);
3011
}
3112

3213
const callAlgo = (algo) => {
33-
this.setState({
34-
algo: algo,
35-
});
36-
37-
this.props.changeAlgo(algo);
14+
props.changeAlgo(algo);
3815
}
3916

4017
return (
@@ -69,7 +46,7 @@ export default class Form extends React.Component {
6946
</div>
7047
<div className="days" id="days">
7148
Days:
72-
<select name="time_window" defaultValue={'10'} onChange={(event) => this.callDays(event)} >
49+
<select name="time_window" defaultValue={'10'} onChange={(event) => callDays(event)} >
7350
<option value="5">5</option>
7451
<option value="10">10</option>
7552
<option value="15">15</option>
@@ -80,7 +57,6 @@ export default class Form extends React.Component {
8057
</div>
8158
</div>
8259
)
83-
}
84-
8560
}
8661

62+
export default Form;

src/components/Table.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import api from "../services/api";
33

44
const Table = (props) => {
55

6-
const [dates, setDates] = useState([]);
7-
const [social_media, setSocialMedia] = useState('');
8-
const [social_type, setSocialType] = useState('');
9-
const [social_logo, setSocialLogo] = useState('');
6+
const [dates, setDates] = useState([]);
7+
const [social_media, setSocialMedia] = useState('');
8+
const [social_type, setSocialType] = useState('');
9+
const [social_logo, setSocialLogo] = useState('');
1010

1111
useEffect(() => {
1212

0 commit comments

Comments
 (0)