JavaScript React Basics Designing Data Flow Adding Players to the Scoreboard

Can someone explain for me why do we use this.setState(this.state)?

I don't understand why do we use "this" and why do we use this.setState(this.state)?

2 Answers

I Dilate
I Dilate
3,972 Points

Hi shyarkhalil,

Do you have any experience with JavaScript yet?

There's a great lesson that will shed some light on how "this" works in JavaScript, inside the Beginning Javascript track. If you haven't covered that yet, then I urge you take it before moving onto attempting anything with React.

I Dilate
I Dilate
3,972 Points

Here's a good summary of how "this" works, from the Full Stack Javascript track...

Understanding "this" in JavaScript

Hi I Dilate! But you didn't answered me why do we use this.setState(this.state)?