-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoggle.js
More file actions
38 lines (34 loc) · 774 Bytes
/
toggle.js
File metadata and controls
38 lines (34 loc) · 774 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
import React from 'react';
import './toggle.css';
class Toggle extends React.Component {
state = {
toggledOn: !!this.props.toggledOn
};
manageClick(evt) {
const newState = !this.state.toggledOn;
this.setState({ toggledOn: newState });
if (this.props.onToggle) {
this.props.onToggle(newState);
}
}
render() {
return (
<div
style={{
display: 'inline-block'
}}
>
<label className="switch">
<input
type="checkbox"
className="input-none"
checked={this.state.toggledOn}
onChange={this.manageClick.bind(this)}
/>
<span className="slider round" />
</label>
</div>
);
}
}
export default Toggle;