TanStackT
TanStack2y ago
18 replies
verbal-lime

Redirect in loader causes infinite loop

Hi,

Basically I want to throw a redirect in the loader function based on some server result. The thing is, the loader is implemented on a dynamic route segment.
Given the following path:

- /
- /model
- - /$model_id
- - - /general
- - - /details

The loader is implemented on the model id route to avoid duplicating the calls when visiting the relative children. Now, whenever I redirect I end up in an endless loop.

How can I achieve this? Hopefully not only by comparing e.g. pathname or similar? Does the parent route loader trigger on purpose when visiting a child?

Any help would be much appreciated!
Was this page helpful?