Read: Class 32 Custom Hooks - Goorob-401-advanced-javascript/amman-javascript-401d1 GitHub Wiki

Custom Hooks :

  • Extract duplicated logic from components
  • Share common functionality
  • Take advantage of useEffect lifecycle
  • Common use cases – make things DRY
  • Handle forms easily
  • Pre-fetch API data
  • Connect to services (like socket.io, Q, etc) Unlike a React component, a custom Hook doesn’t need to have a specific signature. We can decide what it takes as arguments, and what, if anything, it should return. In other words, it’s just like a normal function. Its name should always start with use so that you can tell at a glance that the rules of Hooks apply to it.