v6.4 Data Loader Caching Strategy #8961
-
With data loaders coming in v6.4, will I still need to handle caching queries with a separate solution like react-query or swr? If so, are those solutions which rely on react hooks compatible with react-router data loaders? I see in the docs for remix it says those libraries aren't needed anymore but I'm not using remix. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You won't need to strictly, but if you want your loader functions to prepopulate your react query client as well as return the data, then you can transition from react-query to react router gradually. The 6.4 branch revalidates all the loaders for a URL when you perform an action or use the the useRevalidator hook, at which point anything data returned from the loaders can be considered fresh. That's the stage of migration I'm at currently, and I haven't checked whether any clever magic like the structural comparison of react-query occurs, which would minimise rerenders |
Beta Was this translation helpful? Give feedback.
You won't need to strictly, but if you want your loader functions to prepopulate your react query client as well as return the data, then you can transition from react-query to react router gradually.
The 6.4 branch revalidates all the loaders for a URL when you perform an action or use the the useRevalidator hook, at which point anything data returned from the loaders can be considered fresh.
That's the stage of migration I'm at currently, and I haven't checked whether any clever magic like the structural comparison of react-query occurs, which would minimise rerenders