Skip to content
Source
Sign inSign up
TanStack/router

docs: remove the invalid `context` and `location` arguments from being shown as available in the `loaderDeps` #2091

MergedSeanCassieremerged 1 commit intomain fromrefs/pull/2091/headmerged by SeanCassiere

SeanCassierecommented

We haven't had the context and location arguments present as loaderDeps options, so this corrects this error in Router's documentation.

The reason we don't have location as an argument of loaderDeps is quite simple. If the location changes, the loader would anyways have to be refired (or retrieved from a cache using something like Query). The scenario in which this wouldn't be the case, is if you wanted to prevent this from happening when search params change. This is why only search is provided as its own argument.

The reason we don't have context as an argument of loaderDeps is because, when the root context has been changed, the user is expected to call router.invalidate(). This invalidate call discards all cached data and re-evaluates the entire route-tree. As such, having context as an argument in loaderDeps, makes no sense, since it wouldn't actually contribute anything towards the actual loaderDeps functionality.

    1. ☁️ Nx Cloud Report

      CI is running/has finished running commands for commit 507c608d313fd1f974fc444261886b918ad476c6. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

      📂 See all runs for this CI Pipeline Execution


      ✅ Successfully ran 2 targets

    2. Sent with 💌 from NxCloud.

  • commit: 507c608

    pnpm add https://pkg.pr.new/@tanstack/history@2091
    pnpm add https://pkg.pr.new/@tanstack/react-cross-context@2091
    pnpm add https://pkg.pr.new/@tanstack/react-router@2091
    pnpm add https://pkg.pr.new/@tanstack/react-router-with-query@2091
    pnpm add https://pkg.pr.new/@tanstack/router-cli@2091
    pnpm add https://pkg.pr.new/@tanstack/router-devtools@2091
    pnpm add https://pkg.pr.new/@tanstack/router-generator@2091
    pnpm add https://pkg.pr.new/@tanstack/router-plugin@2091
    pnpm add https://pkg.pr.new/@tanstack/router-vite-plugin@2091
    pnpm add https://pkg.pr.new/@tanstack/start@2091
    pnpm add https://pkg.pr.new/@tanstack/start-vite-plugin@2091

    Open in Stackblitz

    More templates

  • SeanCassiere merged this2423d02

  • SeanCassiere closed this

  • @SeanCassiere is the loader intended to be fired when any property of location changes? (I assume the whole object is replaced on navigate.)

    I noticed the route loader did not appear to fire when only location.hash was changed, so I'm not sure if I missed something or if that's a bug.

  • @SeanCassiere is the loader intended to be fired when any property of location changes? (I assume the whole object is replaced on navigate.)

    I noticed the route loader did not appear to fire when only location.hash was changed, so I'm not sure if I missed something or if that's a bug.

    Please open a new issue for this with a reproduction. This is sounding like a bug, but I can't be sure till someone investigates.

  • Sign in to join this conversation.