Skip to content

Commit fc3127c

Browse files
committed
Refactor examples
1 parent 862624a commit fc3127c

File tree

1 file changed

+22
-49
lines changed

1 file changed

+22
-49
lines changed

examples/src/components/Tags.js

+22-49
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,6 @@ export default class Tags extends Component {
1515
{ text: 'discussion', id: 4 },
1616
],
1717
};
18-
19-
this.changeExample1 = this.changeExample1.bind(this);
20-
this.changeExample2 = this.changeExample2.bind(this);
21-
this.changeExample6 = this.changeExample6.bind(this);
22-
}
23-
24-
changeExample1() {
25-
this.setState({ value1: ['bug', 'discussion'] });
26-
}
27-
28-
changeExample2() {
29-
this.setState({ value2: 3 });
30-
}
31-
32-
changeExample6() {
33-
this.setState({ data6: [
34-
{ text: 'bug_new', id: 1 },
35-
{ text: 'feature_new', id: 2 },
36-
{ text: 'documents_new', id: 3 },
37-
{ text: 'discussion_new', id: 4 },
38-
] });
39-
}
40-
41-
cbOpen() {
42-
console.log('onOpen');
43-
}
44-
45-
cbClose() {
46-
console.log('cbClose');
47-
}
48-
49-
cbSelect() {
50-
console.log('cbSelect');
51-
}
52-
53-
cbChange() {
54-
console.log('cbChange');
55-
}
56-
57-
cbUnselect() {
58-
console.log('cbUnselect');
5918
}
6019

6120
renderBasicUsage() {
@@ -74,7 +33,9 @@ export default class Tags extends Component {
7433
}
7534
/>
7635
77-
<button onClick={this.changeExample1}>set 'bug' 'discussion' value</button>
36+
<button onClick={() => this.setState({ value1: ['bug', 'discussion'] })}>
37+
set 'bug' 'discussion' value
38+
</button>
7839
</div>
7940
);
8041
}
@@ -99,7 +60,9 @@ export default class Tags extends Component {
9960
}}
10061
/>
10162
102-
<button onClick={this.changeExample2}>set 'documents' value</button>
63+
<button onClick={() => this.setState({ value2: 3 })}>
64+
set 'documents' value
65+
</button>
10366
</div>
10467
);
10568
}
@@ -111,11 +74,11 @@ export default class Tags extends Component {
11174
<Select2
11275
multiple
11376
data={['bug', 'feature', 'documents', 'discussion']}
114-
onOpen={this.cbOpen}
115-
onClose={this.cbClose}
116-
onSelect={this.cbSelect}
117-
onChange={this.cbChange}
118-
onUnselect={this.cbUnselect}
77+
onOpen={() => console.log('onOpen')}
78+
onClose={() => console.log('onClose')}
79+
onSelect={() => console.log('onSelect')}
80+
onChange={() => console.log('onChange')}
81+
onUnselect={() => console.log('onUnselect')}
11982
options={{
12083
placeholder: 'search by tags',
12184
}
@@ -180,7 +143,17 @@ export default class Tags extends Component {
180143
}}
181144
/>
182145
183-
<button onClick={this.changeExample6}>reload data value</button>
146+
<button onClick={() => this.setState({
147+
data6: [
148+
{ text: 'bug_new', id: 1 },
149+
{ text: 'feature_new', id: 2 },
150+
{ text: 'documents_new', id: 3 },
151+
{ text: 'discussion_new', id: 4 },
152+
],
153+
})}
154+
>
155+
reload data value
156+
</button>
184157
</div>
185158
);
186159
}

0 commit comments

Comments
 (0)