Created
March 8, 2019 20:31
-
-
Save jahidHn/0e67b46a86b5bd16cf39f09a59accc53 to your computer and use it in GitHub Desktop.
react-state
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
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