-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (33 loc) · 767 Bytes
/
index.js
File metadata and controls
38 lines (33 loc) · 767 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
// Testing with Jest and Enzyme
import React from 'react';
import { createComponent } from 'cf-style-container';
export const Button = createComponent(
({ active }) => ({
padding: '2rem',
backgroundColor: active ? '#ccc' : 'black'
}),
'button',
['onClick']
);
export default class Testing extends React.Component {
constructor(props) {
super(props);
this.state = { active: false };
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.setState(state => ({
active: !state.active
}));
}
render() {
return (
<article>
<h1>11. Testing</h1>
<Button active={this.state.active} onClick={this.handleClick}>
Add item
</Button>
</article>
);
}
}