Skip to content

Instantly share code, notes, and snippets.

@iamso1
Last active November 2, 2020 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamso1/fad49b5881af1bf84879f42838748c6b to your computer and use it in GitHub Desktop.
Save iamso1/fad49b5881af1bf84879f42838748c6b to your computer and use it in GitHub Desktop.
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')
);
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