-
Have anyone successfully used SWR with React Router 6.4 and its new data loading capabilities? While there's an official example of using React Router with React Query, I'd love to see how it would be done using SWR. Since data loading is happening outside of the React render lifecycle, hooks aren't allowed and I was unsure how that would translate into the current SWR API. Any pointers would be much appreciated. 🙂 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Came here to ask the same question. Very interested in making this happen as I could then preload data based on the routes |
Beta Was this translation helpful? Give feedback.
-
Hi, try this repository : https://github.com/osmellodgify/swr-react-router |
Beta Was this translation helpful? Give feedback.
-
https://beta-swr.vercel.app/docs/prefetching#programmatically-prefetch we have a new preload api which could be used for react-router |
Beta Was this translation helpful? Give feedback.
https://beta-swr.vercel.app/docs/prefetching#programmatically-prefetch
we have a new preload api which could be used for react-router