I am trying to understand why this results in a loop :
<button onClick={this.moveRight()}>
but this does not:
<button onClick={this.moveRight}>
Also my my problem is to call a function from another function that is also resulting a loop, why ?
anyfunction(){
anotherfunction();
}
anotherfunction(){
if (this.state.something >1 ){
this.setState(PrevState => {
PrevState.something = PrevState.something -1
return {something = PrevState.something};
});
this.anyfunction()
}
}
Why the if does not break the loop ?