Yes, you read the title right. My thing is working and I have absolutely no idea why -- I've been dying laughing experimenting with new things and it finally works. I then delved into the code and realized I don't know enough about the intricacies of ES6 to really understand what is happening. But I want to understand what is happening here very badly.
I'm on section 3 of the react basics code working on ternarys. As I have a good amount of dev experience in other languages, I decided to take the I go out lesson and make the entire functionality only using one ternary in the actual logic - just as a personal challenge. I got it to work but really for the life of me cannot understand why THIS works. I tried so many different things and just as I was about to give up on my personal mission (write multiple ternarys, or... gasp write an actual if else statement) I decided to try one more thing. The results confused me, shocked me, and just made me laugh. Anyways, here is the code. Someone please explain why this works as expected
Just a note, IGO is my notation for I go out. Thanks in advance!
<!DOCTYPE javascript>
import React from "react"
export default function App() {
const [IGO, setIGO] = React.useState(true)
function handleIGO(){
setIGO(
IGO===false
)
}
return (
<div className="state">
<h1 className="state--title">Do I feel like going out tonight?</h1>
<div className="state--value" onClick={handleIGO}>
<h1>{IGO ? "Yes":"No"}</h1>
</div>
</div>
)
}
