Toggle State with Hooks

PHOTO EMBED

Tue Jun 29 2021 10:10:50 GMT+0000 (Coordinated Universal Time)

Saved by @hisam #react.js #javascript #react #usestate #setstate

import React, { useState } from 'react'

const MyComponent = () => {
  const [toggle, setToggle] = useState(false)

  return(
    <>
      <button onClick={() => setToggle(!toggle)}>Toggle Dropdown Markup</button>
      {toggle && (
        <ul>
          <li>Show me</li>
          <li>Only when</li>
          <li>Toggle === true</li>
        </ul>
      )}
    </>
  )
}
content_copyCOPY

https://dommagnifi.co/2020-12-03-toggle-state-with-react-hooks/