Created
October 6, 2019 07:13
-
-
Save simbathesailor/262fe707b71d0c32b76bc1823554de7c to your computer and use it in GitHub Desktop.
Prop and State (useState example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Job({ job }) { | |
const { title, description } = job; | |
const [shouldShowDescription, setShouldShowDescription] = useState(false); | |
function handleClick(e) { | |
setShouldShowDescription(shouldShowDescription ? false : true); | |
} | |
return ( | |
<> | |
<h3 onClick={handleClick}>{title}</h3> | |
{shouldShowDescription && <p>{description}</p>} | |
<p>{String(shouldShowDescription)}</p> | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment