Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140071

React calling functions resunting in loop

$
0
0

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 ?


Viewing all articles
Browse latest Browse all 140071

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>