Skip to content

Instantly share code, notes, and snippets.

@frickm
Last active September 18, 2019 12:35
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 frickm/42f02bb602ff4c7af3e55a412c37c288 to your computer and use it in GitHub Desktop.
Save frickm/42f02bb602ff4c7af3e55a412c37c288 to your computer and use it in GitHub Desktop.
import { AutoComplete } from 'antd';
function onSelect(value) {
console.log('onSelect', value);
}
class Complete extends React.Component {
state = {
dataSource: [],
}
handleSearch = (value) => {
this.setState({
dataSource: !value ? [] : [
value,
value + value,
value + value + value,
],
});
}
render() {
const { dataSource } = this.state;
return (
<AutoComplete
dataSource={dataSource}
style={{ width: 200 }}
onSelect={onSelect}
onSearch={this.handleSearch}
placeholder="input here"
/>
);
}
}
ReactDOM.render(<Complete />, mountNode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment