/
interactive.js
44 lines (43 loc) · 1.03 KB
/
interactive.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
import React, { Component } from "react";
import { Heading } from "spectacle";
export default class Interactive extends Component {
constructor() {
super();
this.state = {
count: 0
};
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.setState({
count: this.state.count + 1
});
}
render() {
const styles = {
padding: 20,
background: "black",
minWidth: 300,
marginTop: 20,
textTransform: "uppercase",
border: "none",
color: "white",
outline: "none",
fontWeight: "bold",
fontSize: "2em"
};
return (
<div>
{this.state.count < 5 ?
<div>
<Heading size={5} textColor="black">
The button has been clicked {this.state.count} times
</Heading>
<button style={styles} type="button" onClick={this.handleClick}>Click Me</button>
</div> :
<Heading size={5} fit caps textColor="black">Easy there pal</Heading>
}
</div>
);
}
}