I have a select filter, I want to filter my products by category. The state gets updated but the callback of setState is not executed. Basically I want to update my list immediately when the state is changed. Code line 31 doesn't get executed in the try blok, it's also not catching any error.
HTML
<div className="col-md-4 w-25 mt-3 ml-5">
<Select
onChange={this.handleChange}
value={selectedCategory}
placeholder="Select Category"
options={categories}
/>
</div>
JavaScript
handleChange = event => {
console.log(event.value);
this.setState({ selectedCategory: event.value }, () => {
try {
products.pipe(
map(products =>
products
.filter(
product => product.category === this.state.selectedCategory
)
.subscribe(products => {
console.log(products);
this.setState({
items: products,
isLoaded: true
});
})
)
);
} catch (error) {
console.error(error);
}
});
};