How do I change the text and button text back to its original state with an onClick? I know theres a setTimeout but I only want the change to revert back FOR BOTH the button and text when I click on it. Currently I can only use it one way. If i click on it, it changes from Original to new but I will like to change back to Original if i click on it again. Thanks!
Code:
import React, {useState} from 'react'
const Card = () => {
const[text, setText] =useState('original')
const [buttonText, setButtonText] = useState("Original");
return (
<div className='translate uppercase py-5 break-normal text-center mx-4 space-y-2 font-bold'>
<div className="App">
<button className='rounded-full border-black border-solid'
type="submit"
onClick={() => {
setButtonText("New");
setText('New')
}}
>
{buttonText}
</button>
</div>
<h2>{text}</h2>
</div>
)
}
export default Card;