Created
January 31, 2024 13:00
-
-
Save lucifermorningstar1305/fdc5bf6749baf6dff721c6b87def4ea8 to your computer and use it in GitHub Desktop.
Implementation of the FlashCard excercise
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
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