Skip to content

Instantly share code, notes, and snippets.

@simbathesailor
Created October 6, 2019 07:13
Show Gist options
  • Save simbathesailor/262fe707b71d0c32b76bc1823554de7c to your computer and use it in GitHub Desktop.
Save simbathesailor/262fe707b71d0c32b76bc1823554de7c to your computer and use it in GitHub Desktop.
Prop and State (useState example)
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