Start of request, now just prints what is written in text field and reads keypress enter

This commit is contained in:
2017-06-02 14:35:43 +02:00
parent bd3ceb7b6d
commit 545152c888

View File

@@ -0,0 +1,41 @@
import React from 'react';
class SearchRequest extends React.Component {
constructor(props){
super(props)
this.state = {
searchQuery: ''
}
}
_handleKeyPress(e) {
if (e.key === 'Enter') {
console.log('do validate');
}
}
handleChange(event){
this.setState({
searchQuery: event.target.value
})
console.log(this.state.searchQuery);
}
render(){
return(
<div>
<input
type="text"
onKeyPress={this._handleKeyPress}
onChange={this.handleChange.bind(this)}
defaultValue={this.state.searchItem}
/>
</div>
)
}
}
export default SearchRequest;