I have a problem regarding react. Can anyone of you take a look at it?
What’s happening.
1.In category__List component I render <Category__ListItem> Component with “handleOpenModalWithCateogory” function as a prop
Category_List component
{this.props.categories.map(category => (
<Category__ListItem
key={category.id}
category={category}
handleOpenModalWithCategory={this.handleOpenModalWithCategory}
/>
))}
2.handleOpenModalWithCategory is simple function to setState by using event.target.value
handleOpenModalWithCategory = e => {
const selectedCategory = e.target.value;
this.setState({
showModal: true,
selectedCategory,
modalSource: "EDIT"
});
};
“Category_LIstItem” component recieved the handleOpenModalWithCategory as prop and fire the function when a button is clicked.
Category_ListItem Component
<ListItem>
<div>{this.props.category.category}</div>
<button onClick={this.props.handleOpenModalWithCategory}>
edit
</button>
<div>remove</div>
</ListItem>
);
The problem here is when I click the button, it calls the function but without event argument. event argument is undefined. Does anyone have a idea ?
