Requests After Page Change #2045
-
I feel like I must be missing something simple here, but I'm rather stumped. I'm working in an inherited project, using React 17, SWR 0.3.0 and React Router DOM 5.2.0. Yes, I know, outdated. But I can't change them at the moment. We're using SWR throughout the project and it's working really well for the most part. The weirdness I'm seeing is that when I try to create a new page using React Router, and navigate to it from a button in the UI, SWR takes all the API calls from the first page, and calls them on the second page, using the base url of the second page. My routes are something like this: <Route path="/parent/create" exact>
<Create />
</Route>
<Route path="/parent" exact>
<Parent />
</Route> I have a link in the const { data: parent } = useSWR('/parent.json');
const { data: stats } = useSWR('/parent/stats.json');
const { data: usage } = useSWR('/parent/usage.json'); This all works fine. The problem is that when I navigate to
Can anyone help me figure out why these requests are being made, and what I might be missing to avoid them? I have other pages that link from the same |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Nevermind! Figured it out. Was an issue with the ordering of the routes. Before my |
Beta Was this translation helpful? Give feedback.
Nevermind! Figured it out. Was an issue with the ordering of the routes. Before my
/parent/create
route, I had defined/parent/:userId
, which was catchingcreate
as a URL param.