I'm building an ERP-style app using MERN and Redux. My backend is working well, I can add things through my API and all, but I'm having some stupid issues with my front-end.
The idea is that I have item-objects and want to access them through a modal. The modal itself works, and the button used to open the modal actually gets the names of the objects through the loop.
The issue comes in inside the ModalBody - it only fetches the information from the first object in the table. I've tried methods such as this.props.customer, items.customer, this.items.customer and many, many more without success.
It would be cool if I can export the component as a class too, but if it's impossible, that's okay I guess.
Do you guys have any idea on how I can make it work?
render(){
const { items } = this.props.item;
return (
<Container>
<ListGroup>
<TransitionGroup className="shopping-list">
{items.map(({ _id, name, customer, location, dilemma }) =>
<CSSTransition key={_id} timeout={500} classNames="fade">
<ListGroupItem key={_id}>
<Button color="light" style={{ width: "100%" }} onClick={this.toggle}>{name}</Button>
<Modal isOpen={this.state.modal} toggle={this.toggle}>
<ModalHeader toggle={this.toggle} key={_id}>{name}</ModalHeader>
<ModalBody key={index}>
<p>Customer: {customer}</p>
<p>Location: {location}</p>
<p>Dilemma: {dilemma}</p>
</ModalBody>
</Modal>
</ListGroupItem>
</CSSTransition>
)}
</TransitionGroup>
</ListGroup>
</Container>
);
}