Skip to content

useLoaderData causes component to render twice after loader run #4054

Closed

Description

@why-meow

Which project does this relate to?

Router

Describe the bug

I'm writing a page that shows the list of posts with the filters that are taken from the search parameters. On every search parameters change the route should reload with a new (filtered) list of posts, but instead it reloads twice.

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-pcurpwgc?file=src%2Fmain.tsx

Steps to Reproduce the Bug or Issue

  1. Go to the '/posts' page
  2. Click "update" button to update the page search parameters
  3. Observe in the console that child component, that has useLoaderData, renders twice, despite the loader running once.

Expected behavior

I expected component using useLoaderData to be rendered once, but instead it's rendered twice.

Screenshots or Videos

Screen.Recording.2025-04-25.at.19.46.43.mov

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 135.0.7049.96

Additional context

If the loader is synchronous (without Promise, just immediate return), the Child component is rendered once as expected.

Activity

  1. LadyBluenotes commented on Jul 13, 2026

    @LadyBluenotes
    Member

    This no longer reproduces on current main. I tested the same setup with an async loader keyed by search-derived loaderDeps: changing the search parameter ran the loader once and rendered the useLoaderData consumer once.

    The current per-match reactivity was introduced as part of #6704, which prevents loader-data consumers from being updated by unrelated Router state changes.

    I’m going to close this as fixed. If you still see the extra render on the latest Router version, please open a new issue with an updated reproduction and we can compare the exact render sequence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions