if (this.state.foody === "THALI" && this.state.cat === "NONVEG") {
this.setState({ nonvegthali: this.state.nonvegthali++});
} else if (this.state.foody === "THALI" && this.state.cat === "VEG") {
this.setState({ vegthali: this.state.vegthali++ });
} else if (this.state.foody === "SNACK" && this.state.cat === "VEG") {
this.setState({ vegsnack: this.state.vegsnack++ });
} else if (this.state.foody === "SNACK" && this.state.cat === "NONVEG") {
this.setState({ nonvegsnack: this.state.nonvegsnack++});
}
Before I wasn't using setState() and it was obvious to get the "Do not mutate state directly" error. But though after rectifying the code I am getting the same error in the console though the application is running fine and giving me intended output.