-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.js
66 lines (63 loc) · 1.88 KB
/
App.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
61
62
63
64
65
66
import React, {Component} from 'react';
import {ToggleAndDisplayPattern as TogglePattern} from "react-toggle-pattern";
import ActiveElement from "./ActiveElement";
import './App.css';
class App extends Component {
constructor() {
super();
this.state = {
pattern: "A",
patternCorD: "C"
}
}
render() {
const onClickA = () => {
this.setState({
pattern: "B"
})
};
const onClickB = () => {
this.setState({
pattern: "A"
});
};
const onClickC = () => {
this.setState({
patternCorD: "D"
});
};
const onClickD = () => {
this.setState({
patternCorD: "C"
});
};
return (
<div className="App">
<div>
<h2>Pattern A or B</h2>
<TogglePattern pattern={this.state.pattern}>
<button pattern={"A"} onClick={onClickA}>
AAAAAA
</button>
<button pattern={"B"} onClick={onClickB}>
BBBBBB
</button>
</TogglePattern>
</div>
<div>
<h2>Pattern C or D</h2>
<TogglePattern pattern={this.state.patternCorD}>
<button key="C" pattern={"C"} onClick={onClickC}>
CCCCCCC
</button>
<button key="D" pattern={"D"} onClick={onClickD}>
DDDDDDD
</button>
</TogglePattern>
</div>
<ActiveElement />
</div>
);
}
}
export default App;