Last active
June 6, 2018 19:02
-
-
Save itsmunim/61c67adb675ed5df2d99caa114d4e975 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 React from "react"; | |
| class SearchBox extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| query: "" | |
| }; | |
| } | |
| onQueryChange(e) { | |
| this.setState({ query: e.target.value }); | |
| } | |
| render() { | |
| return ( | |
| <div className="input-group mb-3"> | |
| <input | |
| type="text" | |
| value={this.state.query} | |
| onChange={e => this.onQueryChange(e)} | |
| className="form-control" | |
| placeholder={this.props.promptText || 'Search...'}/> | |
| <div className="input-group-append"> | |
| <button | |
| className="btn btn-primary" | |
| onClick={() => this.props.onSearch(this.state.query)} | |
| type="button"> | |
| Search | |
| </button> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| } | |
| export default SearchBox; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment