Skip to content

Instantly share code, notes, and snippets.

@lucifermorningstar1305
Created January 31, 2024 13:00
Show Gist options
  • Save lucifermorningstar1305/fdc5bf6749baf6dff721c6b87def4ea8 to your computer and use it in GitHub Desktop.
Save lucifermorningstar1305/fdc5bf6749baf6dff721c6b87def4ea8 to your computer and use it in GitHub Desktop.
Implementation of the FlashCard excercise
import React, { useState } from "react";
const FlashCard = ({ question }) => {
const [isSelected, setSelected] = useState(false);
const handleClick = () => {
setSelected((s) => !s);
};
const handleMouseLeave = () => {
setSelected((s) => false);
};
return (
<div
onClick={handleClick}
className={isSelected ? "selected" : ""}
onMouseLeave={handleMouseLeave}
>
<p>{isSelected ? question.answer : question.question}</p>
</div>
);
};
export default FlashCard;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment