/
Counter.js
60 lines (57 loc) · 1.47 KB
/
Counter.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
// @flow
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import styles from './Counter.css';
type Props = {
increment: () => void,
incrementIfOdd: () => void,
incrementAsync: () => void,
decrement: () => void,
counter: number
};
export default class Counter extends Component<Props> {
props: Props;
render() {
const {
increment,
incrementIfOdd,
incrementAsync,
decrement,
counter
} = this.props;
return (
<div>
<div className={styles.backButton} data-tid="backButton">
<Link to="/">
<i className="fa fa-arrow-left fa-3x" />
</Link>
</div>
<div className={`counter ${styles.counter}`} data-tid="counter">
{counter}
</div>
<div className={styles.btnGroup}>
<button className={styles.btn} onClick={increment} data-tclass="btn">
<i className="fa fa-plus" />
</button>
<button className={styles.btn} onClick={decrement} data-tclass="btn">
<i className="fa fa-minus" />
</button>
<button
className={styles.btn}
onClick={incrementIfOdd}
data-tclass="btn"
>
odd
</button>
<button
className={styles.btn}
onClick={() => incrementAsync()}
data-tclass="btn"
>
async
</button>
</div>
</div>
);
}
}