# React Hooks

> Small React tools whose names start with use. useState lets a part of the page keep a value.

**Field:** Software Development  
**Category:** Web Development  
**Also known as:** Hooks (React), useState, useEffect, React Hook

## Think of it like

It is like a toy with snap-on parts. Snap one on, and the toy can do a new trick.

## Definition

React Hooks are functions that let a React component use React's features. Their names start with use. useState lets a component remember a value, like a count. useEffect runs code after the page shows, like fetching data. You can also build your own hooks from these. Hooks must be called at the top of a component, never inside an if or a loop.

## Example

Jack's Like button must count clicks. He adds useState(0), and each click calls setLikes to raise the number on screen.

## Example code

```jsx
const [likes, setLikes] = useState(0);
return <button onClick={() => setLikes(likes + 1)}>{likes}</button>;
```

useState gives a value and a way to change it. Each click shows the new count.

## Why it matters

Every modern React component uses them. They are how a component holds data and reacts to change.

## Common mistake

Calling a hook inside an if. React counts on hooks being called in the same order each time.

## Three principles

- **Names start with use.** useState, useEffect, useRef.
- **Top level only.** Never inside an if or a loop.
- **Make your own.** Combine hooks into a new one.

## Related terms

- [React](https://learn.benibix.com/term/development/react)
- [UI State](https://learn.benibix.com/term/development/state)
- [UI Component](https://learn.benibix.com/term/development/component)
- [Virtual DOM](https://learn.benibix.com/term/development/virtual-dom)
- [State Management](https://learn.benibix.com/term/development/state-management)

![A button calls setCount(1), a React Hook that changes state. The component makes a new virtual tree, drawn beside the old one. The two trees are compared, and only one node differs: the text 0 has become 1. An arrow carries just that one change to the real page in the browser.](https://learn.benibix.com/diagrams/dev5-virtual-dom.svg)

---

Source: https://learn.benibix.com/term/development/react-hooks
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
