React

  • useState
  • useEffect
    • perform “side effects” in functional components - which do things beyond the component’s direct rendering, like
      • data fetching, API calls
      • DOM manipulation
      • subscribing to external events
      • timers
      • cleanup - removing event listeners, etc.
    • Runs after every render by default
  • useRef
    • Persists mutable values across component renders without causing re-renders when the value changes
    • returns a mutable ref object, whose .current is the arg passed to useRef
    • ideal for storing values that don’t affect visual output, but need to be maintained, such as
      • prev state vals
      • DOM references
      • Timer Ids
    • commonly used to get direct ref to a DOM element. use cases could be
      • playing or pausing media
      • focusing an input field
      • measuring element dimensions