📅  最后修改于: 2022-03-11 14:58:23.609000             🧑  作者: Mango
//You can use onKeyPress directly on input field. onChange function changes
//state value on every input field change and after Enter
//is pressed it will call a function search().
{this.setState({query: event.target.value})}}
onKeyPress={event => {
if (event.key === 'Enter') {
this.search()
}
}}
/>