forked from iam4x/react-btn-checkbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
executable file
·55 lines (46 loc) · 1.16 KB
/
demo.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
import React, {Component} from 'react';
import {Checkbox, Radio} from './src/index';
import './src/styles/styles.scss';
class Demo extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
checkboxes: {
'First': false,
'Second': true
},
radio: {
'First': false,
'Second': true,
'Third': false,
'Fourth': false
}
};
}
_handleCheckboxes = ::this._handleCheckboxes
_handleCheckboxes(checkboxes) {
return this.setState({checkboxes});
}
_handleRadio = ::this._handleRadio
_handleRadio(radio) {
return this.setState({radio});
}
render() {
return (
<div>
<Checkbox
label='`Checkbox'
options={this.state.checkboxes}
onChange={this._handleCheckboxes} />
<pre>{JSON.stringify(this.state.checkboxes)}</pre>
<Radio
ref='radio'
label='Radio & Uncheckable Radio'
options={this.state.radio}
onChange={this._handleRadio} />
<pre>{JSON.stringify(this.state.radio)}</pre>
</div>
);
}
}
React.render(<Demo />, document.body);