Skip to main content

Command Palette

Search for a command to run...

Introduction to Hooks in React.js

Updated
1 min read
T

Craftsman

Hooks in React are inbuilt functions that allow functional components to access and manage or mutate the state of a React Application.

The state of an Application refers to the whole dynamic data structure and properties of that application.

React Hooks is a concept that was introduced in version 16.8. Prior to this, an application's state was only accessible by class components.

Hooks in React generally follow these three rules.

  • Hooks can only be called inside a functional component. Class components doesn't support hooks
  • Hooks can only be called at the top level of a component ie above the return code block
  • Hooks cannot be conditional and the cannot be placed inside logical code blocks.

This article is only an introduction to my Understanding Hooks in React Series.

In this series, I'll be walking you through the some essential hooks in React. Including:

  1. useState Hook
  2. useReducer Hook
  3. useEffect Hook
  4. useRef Hook
  5. useLayoutEffect Hook
  6. useMemo Hook
G

Good one 🙌

Understanding Hooks in React

Part 1 of 2

In this Series, I'll be introducing you to the essential Hooks in React js. Hooks are inbuilt functions that help us to mutate and control the state of our React application. Let's dive right in 💫

Up next

React.js useState Hook

The useState hook is one of the most common and most essential hooks in React. The useState hook takes one argument at a time, the initial state and it returns 2 values: the current state and a state case that can be assigned dynamically. What is th...

More from this blog

Tonie

16 posts