@@ -15,14 +15,16 @@ export default class Tags extends Component {
15
15
{ text : 'documents' , id : 3 } ,
16
16
{ text : 'discussion' , id : 4 } ,
17
17
] ,
18
+ data9 : [ 'bug' , 'feature' , 'documents' , 'discussion' ] ,
19
+ placeholder9 : 'search by tags' ,
18
20
} ;
19
21
}
20
22
21
- renderBasicUsage ( ) {
23
+ example1 ( ) {
22
24
const { value1 } = this . state ;
23
25
return (
24
26
< div >
25
- Basic usage < br />
27
+ Update `value` < br />
26
28
< Select2
27
29
multiple
28
30
data = { [ 'bug' , 'feature' , 'documents' , 'discussion' ] }
@@ -35,17 +37,17 @@ export default class Tags extends Component {
35
37
/>
36
38
—
37
39
< button onClick = { ( ) => this . setState ( { value1 : [ 'bug' , 'discussion' ] } ) } >
38
- set ' bug' ' discussion' value
40
+ set ` bug` ` discussion` value
39
41
</ button >
40
42
</ div >
41
43
) ;
42
44
}
43
45
44
- renderBasicUsageMutated ( ) {
46
+ example2 ( ) {
45
47
const { value2 } = this . state ;
46
48
return (
47
49
< div >
48
- Basic usage with mutated value< br />
50
+ Update mutated ` value` < br />
49
51
< Select2
50
52
multiple
51
53
data = { [ 'bug' , 'feature' , 'documents' , 'discussion' ] }
@@ -64,13 +66,13 @@ export default class Tags extends Component {
64
66
this . setState ( { value2 : items } ) ;
65
67
} }
66
68
>
67
- set 'feature' ' documents' value
69
+ add ` documents` value
68
70
</ button >
69
71
</ div >
70
72
) ;
71
73
}
72
74
73
- renderDataAsObject ( ) {
75
+ example3 ( ) {
74
76
const { value3 } = this . state ;
75
77
return (
76
78
< div >
@@ -91,13 +93,13 @@ export default class Tags extends Component {
91
93
/>
92
94
—
93
95
< button onClick = { ( ) => this . setState ( { value3 : 3 } ) } >
94
- set ' documents' value
96
+ set ` documents` value
95
97
</ button >
96
98
</ div >
97
99
) ;
98
100
}
99
101
100
- renderCallbacks ( ) {
102
+ example4 ( ) {
101
103
return (
102
104
< div >
103
105
Callbacks< br />
@@ -118,7 +120,7 @@ export default class Tags extends Component {
118
120
) ;
119
121
}
120
122
121
- renderDefaultValue ( ) {
123
+ example5 ( ) {
122
124
return (
123
125
< div >
124
126
Default value< br />
@@ -139,7 +141,7 @@ export default class Tags extends Component {
139
141
) ;
140
142
}
141
143
142
- renderDefaultMultipleValue ( ) {
144
+ example6 ( ) {
143
145
return (
144
146
< div >
145
147
Default multiple value< br />
@@ -160,7 +162,7 @@ export default class Tags extends Component {
160
162
) ;
161
163
}
162
164
163
- renderDynamicUpdateData ( ) {
165
+ example7 ( ) {
164
166
const { data7 } = this . state ;
165
167
return (
166
168
< div >
@@ -188,7 +190,7 @@ export default class Tags extends Component {
188
190
) ;
189
191
}
190
192
191
- renderOptGroups ( ) {
193
+ example8 ( ) {
192
194
return (
193
195
< div >
194
196
Option Groups< br />
@@ -213,26 +215,40 @@ export default class Tags extends Component {
213
215
) ;
214
216
}
215
217
218
+ example9 ( ) {
219
+ const { placeholder9, data9 } = this . state ;
220
+ return (
221
+ < div >
222
+ Update Options< br />
223
+ < Select2
224
+ multiple
225
+ data = { data9 }
226
+ options = {
227
+ {
228
+ placeholder : placeholder9 ,
229
+ }
230
+ }
231
+ />
232
+ —
233
+ < button onClick = { ( ) => this . setState ( { placeholder9 : 'test' , data9 : [ 'feature' ] } ) } >
234
+ set `placeholder` and `data`
235
+ </ button >
236
+ </ div >
237
+ ) ;
238
+ }
216
239
217
240
render ( ) {
218
241
return (
219
242
< div >
220
- { /* example 1 */ }
221
- { this . renderBasicUsage ( ) } < br />
222
- { /* example 2 */ }
223
- { this . renderBasicUsageMutated ( ) } < br />
224
- { /* example 3 */ }
225
- { this . renderDataAsObject ( ) } < br />
226
- { /* example 4 */ }
227
- { this . renderCallbacks ( ) } < br />
228
- { /* example 5 */ }
229
- { this . renderDefaultValue ( ) } < br />
230
- { /* example 6 */ }
231
- { this . renderDefaultMultipleValue ( ) } < br />
232
- { /* example 7 */ }
233
- { this . renderDynamicUpdateData ( ) } < br />
234
- { /* example 8 */ }
235
- { this . renderOptGroups ( ) }
243
+ { this . example1 ( ) } < br />
244
+ { this . example2 ( ) } < br />
245
+ { this . example3 ( ) } < br />
246
+ { this . example4 ( ) } < br />
247
+ { this . example5 ( ) } < br />
248
+ { this . example6 ( ) } < br />
249
+ { this . example7 ( ) } < br />
250
+ { this . example8 ( ) } < br />
251
+ { this . example9 ( ) } < br />
236
252
</ div >
237
253
) ;
238
254
}
0 commit comments