'How can I map a List Group Item with axios on ReactJS
I want that depending on the selected option of the list it shows me the products of that specific category. I have not found the way to do it, I did something like this but I don't know how to save the value of id_category to show the products depending on that id_category.
<ListGroup value={this.state.CategoryId} onClick={this.GetProducts}>
<ListGroup.Item><h3>Menu</h3></ListGroup.Item>
{this.state.Categories.map((e) => {
return <ListGroup.Item action href={e.id_category} value={e.id_category}>{e.id_category}</ListGroup.Item>;
})}
</ListGroup>
<Tab.Content>
{this.state.Products.map((e) => {
return <Tab.Pane eventKey={e.id_category}>
<ListGroup>
<ListGroup.Item>
<h5>{e.name_product}</h5>
<h6>{e.price_product}</h6>
</ListGroup.Item>
</ListGroup>
</Tab.Pane>;
})}
</Tab.Content>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
