2022-04-20
Hello developer!, glad to see you again.
This is a react-curve, open source project where I can share and start creating small UI components in the way I understood the concepts to build large scale projects .
This week we created a toggle app that show and hide content when click on button in react.
To create a toggle component; We have to :
import React, {useState} from 'react';
const Toggle = () => {
const [show, setShow] = useState(true);
return (
<div className="showHide">
<h2>Toggle</h2>
<div>
<button onClick={() => setShow(!show)}>
{show ? "Hide Welcome" : "Show Welcome"}
</button>
{show && <h2>Hi, How are you ? </h2>}
</div>
</div>
);
}
export default Toggle;
Thank you for reading and any contribution is more than welcome in the threads below!