Skip to content

Instantly share code, notes, and snippets.

@jonathanharrell
Last active July 7, 2018 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanharrell/65dbd13d2f7c858b1dac3db8519d71c9 to your computer and use it in GitHub Desktop.
Save jonathanharrell/65dbd13d2f7c858b1dac3db8519d71c9 to your computer and use it in GitHub Desktop.
React SearchSelect Component (with render props)
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