Skip to content

useLoaderData causes component to render twice after loader run #4054

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.

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