<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/react-hooks-internally-how-usestate-useeffect-other-hooks-actually-work-z0xnfhcya" -->

---
title: React Hooks Internally: How useState, useEffect & Other...
description: An explainer walks through how React Hooks work under the hood, covering how state is stored outside the component function via the Fiber architecture, why...
canonical: https://daily.dev/posts/react-hooks-internally-how-usestate-useeffect-other-hooks-actually-work-z0xnfhcya
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: React Hooks Internally: How useState, useEffect & Other Hooks Actually Work | daily.dev
og:description: An explainer walks through how React Hooks work under the hood, covering how state is stored outside the component function via the Fiber architecture, why...
og:url: https://daily.dev/posts/react-hooks-internally-how-usestate-useeffect-other-hooks-actually-work-z0xnfhcya
og:image: https://api.daily.dev/og/posts/Z0XNfHCYa.png
og:image:alt: React Hooks Internally: How useState, useEffect & Other Hooks Actually Work
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# React Hooks Internally: How useState, useEffect & Other Hooks Actually Work

**[Medium](https://daily.dev/sources/medium_js)** · 13 min read · 44 upvotes · 2 comments

## Summary

An explainer walks through how React Hooks work under the hood, covering how state is stored outside the component function via the Fiber architecture, why Hook call order matters (and why Hooks can't be conditional), how useState and useEffect manage update queues and dependency comparisons, the mount vs update dispatcher pattern, closures and stale state snapshots, useRef vs useState, useMemo/useCallback memoization, custom Hooks composition, and the render vs commit lifecycle including batching.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@salim99/react-hooks-internally-how-usestate-useeffect-other-hooks-actually-work-3ea5173a32c8>

## Questions this post answers

### why can't I call useState inside an if statement in React

React hooks must be called in the same order on every render because React associates each hook with a position in a linked list tied to the component's Fiber, not by name. If a hook is called conditionally, the hook sequence shifts between renders (e.g., hook #1 mapping to a different state variable), so React can no longer reliably match state to the right hook, corrupting component state.

_Developers debugging hook-order errors can dig into how React's fiber model works via daily.dev._

### why does useCount inside my onClick handler log the old state value after calling setCount

Because state variables belong to the render they were created in via a closure, and setCount schedules an update rather than mutating the variable immediately. Calling setCount(1) then logging count in the same handler still logs the value from the current render (e.g., 0), since the update is only reflected in count on the next render after React reconciles and commits.

_Anyone chasing stale closure bugs in React state updates can find deeper explainers through daily.dev._

### what's the difference between using setCount(count + 1) three times versus setCount(c => c + 1) three times in React

Calling setCount(count + 1) three times in a row typically produces a final state of 1, because each call reads the same stale count value (0) from the current render's closure. Using the functional form setCount(c => c + 1) three times processes each update against the latest queued state, producing 0→1→2→3, ending at 3.

_Developers deciding between direct and functional state updates can track React patterns like this via daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@pdfopsdev** · 2 upvotes

> one thing this glosses over: useRef reuses the same linked-list hook slot as useState under the hood, it just skips the update-queue path entirely. that's why mutating ref.current never triggers a re-render, it's not magic, there's just no dispatch wired up to it.

**@agustinbarrientos** · 1 upvotes

> Great explanation of hook order. The list example is simple enough to remember without falling back on "React says so," and the update queue walkthrough follows naturally from it. Thanks for making this so easy to follow.

## Similar posts on daily.dev

- [Meet React Hooks](https://daily.dev/posts/meet-react-hooks-r38j4jwfp) · Kirupa · 1 upvotes · 0 comments
- [The Only React Hooks Guide You’ll Actually Finish Reading.](https://daily.dev/posts/the-only-react-hooks-guide-you-ll-actually-finish-reading--kd819szsi) · Coins Bench · 187 upvotes · 7 comments
- [React has changed, your Hooks should too – Frontend Masters Blog](https://daily.dev/posts/react-has-changed-your-hooks-should-too-frontend-masters-blog-zyf4bnedj) · Frontend Masters · 52 upvotes · 6 comments
- [How React Works Internally: Virtual DOM, Reconciliation, and Rendering](https://daily.dev/posts/how-react-works-internally-virtual-dom-reconciliation-and-rendering-en38kquvn) · Medium · 2 upvotes · 0 comments
- [React for Vue Developers, 2: State, Effects, Re-renders](https://daily.dev/posts/react-for-vue-developers-2-state-effects-re-renders-lf4kx00ba) · Telerik · 13 upvotes · 1 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#react](https://daily.dev/tags/react), [#react-hooks](https://daily.dev/tags/react-hooks)

[View this post on daily.dev](https://daily.dev/posts/react-hooks-internally-how-usestate-useeffect-other-hooks-actually-work-z0xnfhcya)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"React Hooks Internally: How useState, useEffect \u0026 Other Hooks Actually Work","url":"https://daily.dev/posts/react-hooks-internally-how-usestate-useeffect-other-hooks-actually-work-z0xnfhcya","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/react-hooks-internally-how-usestate-useeffect-other-hooks-actually-work-z0xnfhcya"},"datePublished":"2026-09-11T22:15:27.896Z","dateModified":"2026-09-11T22:29:25.569Z","description":"An explainer walks through how React Hooks work under the hood, covering how state is stored outside the component function via the Fiber architecture, why...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/087ff25dd74a3fe0599e53bb36aedc89?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/087ff25dd74a3fe0599e53bb36aedc89?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":2,"discussionUrl":"https://daily.dev/posts/react-hooks-internally-how-usestate-useeffect-other-hooks-actually-work-z0xnfhcya","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":44},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":2}],"keywords":"javascript,react,react-hooks","timeRequired":"PT13M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"React Hooks Internally: How useState, useEffect \u0026 Other Hooks Actually Work"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/react-hooks-internally-how-usestate-useeffect-other-hooks-actually-work-z0xnfhcya","comment":[{"@type":"Comment","text":"one thing this glosses over: useRef reuses the same linked-list hook slot as useState under the hood, it just skips the update-queue path entirely. that’s why mutating ref.current never triggers a re-render, it’s not magic, there’s just no dispatch wired up to it.","datePublished":"2026-09-12T18:02:23.006Z","url":"https://daily.dev/posts/Z0XNfHCYa#c-SfxI6f09p","author":{"@type":"Person","name":"PDFops","url":"https://daily.dev/pdfopsdev","image":"https://media.daily.dev/image/upload/s---8isRBKc--/f_auto/v1782922291/avatars/avatar_orjMeK8QKaaVZwGq7ScPz?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Great explanation of hook order. The list example is simple enough to remember without falling back on “React says so,” and the update queue walkthrough follows naturally from it. Thanks for making this so easy to follow.","datePublished":"2026-09-13T08:27:39.085Z","url":"https://daily.dev/posts/Z0XNfHCYa#c-x9svNdu6A","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/react-hooks-internally-how-usestate-useeffect-other-hooks-actually-work-z0xnfhcya#faq","mainEntity":[{"@type":"Question","name":"why can't I call useState inside an if statement in React","acceptedAnswer":{"@type":"Answer","text":"React hooks must be called in the same order on every render because React associates each hook with a position in a linked list tied to the component's Fiber, not by name. If a hook is called conditionally, the hook sequence shifts between renders (e.g., hook #1 mapping to a different state variable), so React can no longer reliably match state to the right hook, corrupting component state. Developers debugging hook-order errors can dig into how React's fiber model works via daily.dev."}},{"@type":"Question","name":"why does useCount inside my onClick handler log the old state value after calling setCount","acceptedAnswer":{"@type":"Answer","text":"Because state variables belong to the render they were created in via a closure, and setCount schedules an update rather than mutating the variable immediately. Calling setCount(1) then logging count in the same handler still logs the value from the current render (e.g., 0), since the update is only reflected in count on the next render after React reconciles and commits. Anyone chasing stale closure bugs in React state updates can find deeper explainers through daily.dev."}},{"@type":"Question","name":"what's the difference between using setCount(count + 1) three times versus setCount(c =\u003e c + 1) three times in React","acceptedAnswer":{"@type":"Answer","text":"Calling setCount(count + 1) three times in a row typically produces a final state of 1, because each call reads the same stale count value (0) from the current render's closure. Using the functional form setCount(c =\u003e c + 1) three times processes each update against the latest queued state, producing 0→1→2→3, ending at 3. Developers deciding between direct and functional state updates can track React patterns like this via daily.dev."}}]}
```

