Last active
November 2, 2020 01:39
-
-
Save iamso1/fad49b5881af1bf84879f42838748c6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Select from '../src/component/Select'; | |
function onChange(value) { | |
console.log(`selected`, value); | |
} | |
function onBlur() { | |
console.log('blur'); | |
} | |
function onFocus() { | |
console.log('focus'); | |
} | |
function onSearch(val) { | |
console.log('search:', val); | |
} | |
const options = [ | |
{ value: 'jack', label: 'jack' }, | |
{ value: 'rose', label: 'rose' }, | |
{ value: 'marry', label: 'marry' }, | |
]; | |
ReactDOM.render( | |
<React.StrictMode> | |
<Select | |
showSearch | |
allowClear | |
labelInValue | |
mode="multiple" | |
style={{ width: 200 }} | |
placeholder="Select a person" | |
optionFilterProp="children" | |
onChange={onChange} | |
onFocus={onFocus} | |
onBlur={onBlur} | |
onSearch={onSearch} | |
filterOption={(input, option) => | |
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 | |
} | |
style={{ width: 200 }} | |
placeholder="Select a person" | |
optionFilterProp="children" | |
options={options} | |
></Select> | |
</React.StrictMode>, | |
document.getElementById('root') | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Select } from 'antd'; | |
const { Option } = Select; | |
const ITSSelect = ({ options, ...props }) => { | |
const optionList = options.map((option) => { | |
return <Option value={option.value}>{option.label}</Option>; | |
}); | |
return <Select {...props}>{optionList}</Select>; | |
}; | |
export default ITSSelect; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment