I’m trying to count how many times map function (loop) executing?
but it gives this error:
Maximum update depth exceeded. This can happen when a component
repeatedly calls setState inside componentWillUpdate or
componentDidUpdate. React limits the number of nested updates to
prevent infinite loops.
counterFun = () => {
const { Counter } = this.state;
this.setState({ Counter: Counter + 1 })
};
something.map((item)=>{
return(
this.counterFun();
)
})
How can I count through map function OR any loop?
Thank you.