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 trialGarrett Hughes
Python Development Techdegree Student 32,971 PointsI can't figure out what's suppose to go here. I've reviewed the videos a few times. I guess I'm just missing it.
Complete the code so that the isConfirmed state updates its value based on the previous state.
confirmGuest = () => {
this.setState( prevState => ({
isConfirmed: !___.isConfirmed
}));
}
2 Answers
Garrett Hughes
Python Development Techdegree Student 32,971 PointsOh, because it's just changing a boolean value to its opposite. I was thinking it wasnted a '!== prevState.isConfirmed" or something like that and it wasn't clicking lol Dumb question.
Garrett Hughes
Python Development Techdegree Student 32,971 PointsOoo. It's just "prevState". But why is there an '!' before it? That's what was throwing me off.
Gabbie Metheny
33,778 Points!
is the logical NOT operator. In this case, it's basically just a quick way of flipping the boolean value. If the isConfirmed
state was true
, firing this event handler would change it to false
; and if it started as false
, the handler would flip it to true
. Similar to using if/else if
logic, but without explicitly writing it all out, since you just want the boolean to flip to the only other option.