Closed henrikvilhelmberglund closed 11 months ago
It seems like this is related to shouldRevalidate so I took a look at https://github.com/oedotme/generouted/issues/103, however that only allows the function in normal routes and I need it in the _app.jsx layout route.
I'm not sure what I need to add in routes.tsx in order to be able to add a ShouldRevalidate function in there.
Hey @henrikvilhelmberglund, yes exactly you should add a custom routes.tsx
and accept ShouldRevalidate
from the _app.tsx
. Here's a working example based on the example you've provided: https://stackblitz.com/edit/github-cvgpop?file=src%2Froutes.tsx%3AL87
Hope that helps!
Thanks for the example, it works perfectly!
Describe the Bug
Not sure if this is a bug or me not knowing what I'm doing but I have an issue where if I click a link that is the same URL as the route I'm on the loader in my layout (_app.jsx) reruns.
I want to basically fetch once in the global layout and reuse that data everywhere using useOutletContext but if I click the active page link in my nav the loader reruns as if I refreshed to page. This doesn't happen if I go to / and back to the route for example.
Anyway this is easier seen than explained so I made a small repro below. I noticed it doesn't really work in stackblitz though so you may have to clone it locally.
Generouted Version
1.15.8
Your Example Website or App or Reproduction
https://stackblitz.com/github/henrikvilhelmberglund/generouted-layout-fetch?file=src%2Fpages%2F_app.jsx
Steps to Reproduce the Bug or Issue
(clone locally to make the fetch work (???))
Expected Behavior
Expected: You see the same cat.
Screenshots or Videos
No response
Platform
Additional context
No response