Skip to content

Router context invalidate Promise resolve does not invalidate context #2072

Description

@ZahidHasan321

Describe the bug

In the code below, which was suppose to invalidate the context and navigate to the following route. for context i'm following the example given in tanstack authenticated routes example. Even after navigation the context isn't invalidated which I can see in console log. It results in redirect to login page not working properly after clicking logout and just stuck in the "/" page.

router.invalidate().finally(() => { navigate({ to: "/" }); });

It only invalidates or I can see it invalidates when I manually reload the page, which means during the navigation the context doesn't invalidate.

PS: I do have an api request in the logout function.

Your Example Website or App

...

Steps to Reproduce the Bug or Issue

Following the tanstack example locally.

https://stackblitz.com/edit/tanstack-router-4achrw?file=src%2Froutes%2F_auth.tsx

Expected behavior

Router context should've been already invalid in .finally or .then even before navigating.

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions