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>
  )
}
CodeWithTaylor