Getting undefined value of handleClick() in countStat(). What is the exact problem happening right there? What should I change in the code?
class Widget extends Component {
state = {
good: 0,
neutral: 0,
bad: 0
};
handleClick(event) {
const id = event.target.id;
return id;
}
countStat(id, e) {
id = this.handleClick(e);
if (id === "good") {
this.setState(prevState => ({
good: prevState.good + 1
}));
}
}
render() {
return (
<li className={classes.Button}>
<button onClick={this.countStat} id="good">
Good
</button>
</li>
);
}
}
export default Widget;