What are React Hooks ?

Hooks were added to React in version 16.8

Hooks allow function components to have access to state and other React features. Because of this, class components are generally no longer needed.

Hooks Rules

There are 3 rules for hooks:

  • Hooks can only be called inside React function components.
  • Hooks can only be called at the top level of a component.
  • Hooks cannot be conditional.

Custom Hooks

If you have stateful logic that needs to be reused in several components, you can build your own custom Hooks.

Youtube Link: Custom Hooks Short Course