Closed farhan687 closed 8 years ago
Code snippet:
<Select2
multiple={false}
data={ ['test', 'test1', 'cool'] }
value={this.state.selectedType}
options={{
placeholder: 'Choose or create a new type',
tags: {true}
}}
onChange={this.onTypeSelection}
/>
thanks a lot for creating such wrapper, it saved my lot of time
You are welcome!
Please try the following code:
<Select2
multiple={false}
data={ ['', 'test', 'test1', 'cool'] }
value={this.state.selectedType}
options={{
placeholder: 'Choose or create a new type',
tags: true,
allowClear: true,
}}
onChange={this.onTypeSelection}
/>
Thanks @rkit, it works.
I am using tags true when I try to create a new tag, Select2 automatically choose the first option though it is not executing onchange event but it should be empty if I didn't select anything already.
other than this wrapper works pretty well, thanks a lot for creating such wrapper, it saved my lot of time.