Hooks API - andrewkyllo-401-advanced-javascript/seattle-javascript-401d34 GitHub Wiki

Hooks

  • React hooks allow you to easily create and manage state in a functional component
  • Hooks are Javascript functions but they impose additional rules:
    • Hooks must be named with use prefix
    • Only call Hooks at the top level. Dont call Hooks inside loops, conditions, or nested functions
    • Only call Hooiks from React function components. Dont call Hooks from regular javascript functions

Built in Hooks

useState() Returns a stateVariable and setterFunction for your to use to manage state in a function components