react-router
react-router copied to clipboard
[Docs]: Docs for shouldRevalidate make it sound like it is only for opting out
Describe what's incorrect/missing in the documentation
The docs for shouldRevalidate only mention the case for opting out of data revalidation. From my investigation and testing it also supports the opposite case of triggering revalidation when the default would have been false. It should say that you can also opt-in when the default is false.
This is relevant to react-router-relay where we need to force revalidation when the relay environment changes and the queries have been disposed of. I had a question from a maintainer of react-router-relay asking whether this was a suitable usage of shouldRevalidate. I'm pretty sure that it is but it would be much more reassuring if the docs mention it and we can rely on it staying that way.
I cant understand. I thought that the shouldRevalidate in remix is only opt out and by default all the loaders will get called. But they should also have something like in the vite.config so that we can change this behaviour from opt out to opt in.
I'm not using remix so I can't comment on the default there.
You can see in shouldRevalidateLoader that you can return true or false and it will be respected. If it was opt out only then a true value would be ignored. The default is only used when shouldRevalidate is falsey.
Just to be clear, this behaviour is good and needed for react-router-relay so please don't change it. This issue is just about the documentation. The docs should remove all mention of opt out/in. That is making it more confusing than it needs to be. It should say something along the lines of overriding the default behaviour.
The docs are definately a pain when finding something. That's the point why people keep using next js because even if there is weird caching behaviour but it's documented pretty well ngl. I think I will be using next for my new project but looking forward for react router v7 🤞.