Toggle text

mail@pastecode.io avatar
unknown
javascript
3 years ago
382 B
14
Indexable
Never
import React from "react";

const Test = () => {
  const [showText, setShowText] = useState(false);

  return (
    <React.Fragment>
      <div>
        {showText && <h1>Hello World</h1>}
        <p>Lorem ipsum dolor sit amet.</p>
      </div>
      <button onClick={() => setShowText(!showText)}>Toggle</button>
    </React.Fragment>
  );
};

export default Test;