Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Arturo Goicochea
8,077 PointsWhy can we change the value of previousTime to now before comparing (subtracting) now - previousTime?
Why doesn't the make now == previousTime?
Arturo Goicochea
8,077 PointsArturo Goicochea
8,077 PointsMy suspicion is that since everything is inside of the setState function, we are changing the value of previousTime first, then actually referencing the state's current value (by using this, state.previousTime) that has still not changed. And after all of this is run locally, it is then that we change the previousTime value outside of our function.