Skip to content

Instantly share code, notes, and snippets.

@jahidHn
Created March 8, 2019 20:31
Show Gist options
  • Save jahidHn/0e67b46a86b5bd16cf39f09a59accc53 to your computer and use it in GitHub Desktop.
Save jahidHn/0e67b46a86b5bd16cf39f09a59accc53 to your computer and use it in GitHub Desktop.
react-state
const reviews = [
{
"id": 1,
"rating": 5,
"label": [
"Sports",
"Sleep"
],
},
{
"id": 3,
"rating": 5,
"label": [
"Sports",
"Pain"
],
},
];
class SelectCreateFilter extends React.Component {
state = {
multi: null,
data: reviews,
health: healthBenefitsOptions,
category: productCategoryOptions,
products: productOptions,
};
handleChange = name => value => {
this.setState({
[name]: value,
data: this.state.data.filter() //how to perform the data mathcing to reviews.label
});
};
render() {
return (
<div>
<Select
options={groupedOptions}
components={components}
value={multi}
onChange={this.handleChange('multi')}
placeholder="Select multiple tags or products for reviews"
isMulti
isSearchable
/>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment