Last active
September 18, 2019 12:35
-
-
Save frickm/42f02bb602ff4c7af3e55a412c37c288 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 { 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