-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpure-component.htm
More file actions
40 lines (34 loc) · 871 Bytes
/
Copy pathpure-component.htm
File metadata and controls
40 lines (34 loc) · 871 Bytes
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>React Pure Component</title>
</head>
<body>
<div id="root"></div>
<script src="https://unpkg.com/react@15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<script type="text/jsx">
class CounterButton extends React.PureComponent {
constructor(props) {
super(props);
this.state = {count: 1};
}
render() {
return (
<button
color={this.props.color}
onClick={() => this.setState(prevState => ({count: prevState.count + 1}))}>
Count: {this.state.count}
</button>
);
}
}
ReactDOM.render(
<CounterButton color="red" />,
document.getElementById('root')
);
</script>
</body>
</html>