React Hooks cheat sheet: Best practices with examples (best example)::

PHOTO EMBED

Sun Mar 12 2023 06:46:43 GMT+0000 (Coordinated Universal Time)

Saved by @bhushan03 #javascript

const MultipleStateVars = () => {
  const [age, setAge] = useState(19)
  const [siblingsNum, setSiblingsNum] = 
    useState(10)

  const handleAge = () => setAge(age + 1)
  const handleSiblingsNum = () => 
      setSiblingsNum(siblingsNum + 1)
 

  return (
    <div>
      <p>Today I am {age} Years of Age</p>
      <p>I have {siblingsNum} siblings</p>

      <div>
        <button onClick={handleAge}>
          Get older! 
        </button>
        <button onClick={handleSiblingsNum}>
            More siblings! 
        </button>
      </div>
    </div>
  )
}
content_copyCOPY

https://blog.logrocket.com/react-hooks-cheat-sheet-solutions-common-problems/