Let's say I have a function:
import React from "react";
const Test = () => {
return (
<React.Fragment>
<h1>Hello World</h1>
</React.Fragment>
);
};
export default Test;
I want to toggle the Hello World text on and off with a button. How would I achieve this? I have looked at:
And none of them helped really. They used this.state, to which I got a type error, and then I started wondering if I should use a variable type function or not, as all the tutorials I've looked at use class instead. So my question is, how would I achieve toggling text in a variable type function?
If you need anymore information, or if my question was poorly phrased, please tell me. Any help is very much appreciated. Thank you!