Created
December 20, 2017 23:06
-
-
Save pnispel/1c45ae1d656e47b1b47d455a9a297ae0 to your computer and use it in GitHub Desktop.
Filter
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
class Filter { | |
render() { | |
const { onChange, options } = this.props | |
return ( | |
<select onChange={onChange}> | |
{options.map((option) => <option value={option.value}>{option.label}</option>)} | |
</select> | |
) | |
} | |
} |
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
class Parent { | |
onFilterUpdate(e) { | |
const filter = e.target.value /* new_arrivals | best_sellers */ | |
api.getResultsWithFilter({ filter }) | |
} | |
render() { | |
const filterOptions = [ | |
{value: 'new_arrivals', label: 'new arrivals'}, | |
{value: 'best_sellers', label: 'best sellers'}, | |
] | |
return ( | |
<Filter onChange={this.onFilterUpdate.bind(this)} options={filterOptions} /> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment