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

JavaScript React Components (2018) React Component Patterns The React Challenge

ComponentDidUpdate() does not have most up to date state

HI, this question is in regards to the "The React Challenge". I am trying to use ComponentDidUpdate() as a way to get the most up to date state. However, the state seems to be one step behind.

So whenever the ComponentDidUpdate is triggered, my function is also triggered. My functions does some calculations to the highest score values. I would presume my function should have the CURRENT state at this point since it is being triggered inside ComponentDidUpdate()....But it doesn't (instead it is getting the previous state)

Any idea why?