TanStackT
TanStack2y ago
16 replies
progressive-amaranth

Using navigate in useEffect leads to false routing

1. I navigate via a
<Link>
to the
/about
page.
2. The component of the
/about
page has a
useEffect
which executes
navigate
function.
3. The
navigate
only applies an
id
query param, not more.
4. Expect: I would expect the final path to be /about?id=1234
5. Actual: The router navigates back to the home route
/
I'm coming from and applies the id=1234 query param there instead.

I created a repo with a reproduction and some additional notes in the README.
Reproduction: https://github.com/lukaskoeller/tanstack-react-router-useEffect-navigate-reproduction

I'm not sure if it's something I do wrong or rather a library bug, that's why I'm asking here first. Anybody that can help?
Was this page helpful?