Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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>
  )
}
Source by spectrum.chat #
 
PREVIOUS NEXT
Tagged: #useState #settoggle
ADD COMMENT
Topic
Name
2+2 =