react, ( usestate to toggle an element) code example
Example: useState settoggle
Pierre Ortega
@4ever
1:46am
const Toggle = () => {
const [isToggledOn, setToggle] = useState(false)
const toggle = () => setToggle(!isToggledOn)
return (
<button onClick={toggle}>
{isToggleOn ? 'ON' : 'OFF'}
</button>
)
}