Last active
July 7, 2018 20:17
-
-
Save jonathanharrell/65dbd13d2f7c858b1dac3db8519d71c9 to your computer and use it in GitHub Desktop.
React SearchSelect Component (with render props)
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
class SearchSelect extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
results: props.options | |
} | |
} | |
searchList(event) { | |
const results = this.props.filterMethod(this.props.options, event.target.value) | |
this.setState({ results }) | |
} | |
render() { | |
return this.props.render({ | |
results: this.state.results, | |
searchList: (event) => this.searchList(event) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment