NextJS: onClick change back to previous state

Viewed 26

I have a NextJS application with a switch button, that through an onClick event changes a text value:

const initialText = '$ 84,000.00';
const [buttonText, setButtonText] = useState('$ 79,800.00');


const handleClick = () => {
setButtonText('13.800 EUR');

};

In this case, '$84,000,00' and '79,800.00' are changed to '13.800 EUR.'

How can I set another onClick event for this switch button that reverts the 13'.800 EUR' back to the initial state of '$84,000,00' and '79,800.00' ?

0 Answers
Related