Skip to content

Bug: Rendered more hooks than during the previous render when component calls use(thenable) after hydration in a specific transition #33580

Open
@RobPruzan

Description

@RobPruzan

Observing Rendered more hooks than during the previous render being incorrectly thrown when at least all the following conditions are met:

  • the app is hydrated using hydrateRoot
  • a subtree, wrapped in an error boundary and suspense, throws an error during render
  • a subtree runs an effect that:
    • causes a cascading update
    • immediately after runs a startTransition
    • the startTransition updates state in a parent component to a newly created Promise
    • the parent state conditionally reads the state with use only when its a promise
  • at least 1 hook, that cannot be called conditionally, is ran after the use call in the parent component

Remove any one conditions and the Rendered more hooks than during the previous render behavior no longer exists.

Wrapping the client entry point (the subtree that calls use) in a Suspense boundary also causes the Rendered more hooks than during the previous render to no longer exist.

Every condition that changes the outcome of the reproduction is documented inline with the source code.

Related issues (in next.js & react)
#33556
vercel/next.js#63121
vercel/next.js#63388
vercel/next.js#78396
vercel/next.js#80483

React version:

  • react@19.1.0
  • react@19.2.0-canary-197d6a04-20250424

Steps To Reproduce

  1. git clone https://github.com/RobPruzan/rendered-more-hooks-repro
  2. pnpm install && pnpm run dev
  3. open browser console
  4. expect:
 Uncaught Error: Rendered more hooks than during the previous render.
    at updateWorkInProgressHook (react-dom_client.js?v=457007cf:4342:19)
    at updateMemo (react-dom_client.js?v=457007cf:5063:20)
    at Object.useMemo (react-dom_client.js?v=457007cf:16761:20)
    at exports.useMemo (chunk-E6KUT42S.js?v=19f5b077:916:36)
    at Page (/src/BugRepro.tsx:38:3)
    at react-stack-bottom-frame (react-dom_client.js?v=457007cf:17422:20)
    at renderWithHooks (react-dom_client.js?v=457007cf:4204:24)
    at updateFunctionComponent (react-dom_client.js?v=457007cf:6617:21)
    at beginWork (react-dom_client.js?v=457007cf:7652:20)
    at runWithFiberInDEV (react-dom_client.js?v=457007cf:1483:72)

Link to code example:
https://codesandbox.io/p/github/RobPruzan/rendered-more-hooks-repro/sync-again

you may need to refresh the codesandbox at least once to see the error. I'm not sure if this is because non determinism, or codesandbox is swallowing some of the logs. I don't observe any non determinism locally.

The current behavior

React throws Rendered more hooks than during the previous render and does not finish rendering

The expected behavior

The app to render with no uncaught errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions