<Link>, useNavigate makes that variable routes are not updated -> they need a reload
Hi, using a Link or useNavigate on
product/1 for example, makes that sometime, it will render the product/2 because it was in cache, then if I reload the page, the good content is show. Can I do something about it ?44 Replies
harsh-harlequinOPβ’2y ago
for example, if I click on this card showing
product1 then product2, on product/2 it will show the content of product/1eastern-cyanβ’2y ago
please provide a minimal complete example on e.g. Stackblitz
harsh-harlequinOPβ’2y ago
i'll be complex to reproduce the whole thing I think
i'll try
eastern-cyanβ’2y ago
focus on it being minimal
harsh-harlequinOPβ’2y ago
It works with my backend and requests
so idk
if I really can
but i'll try to screen record
harsh-harlequinOPβ’2y ago

harsh-harlequinOPβ’2y ago
@Manuel Schiller you can see the url at the top
the 2nd product on which I clicked is 'product 2'
then I refresh and it shows the correct data
and this is my route:
eastern-cyanβ’2y ago
check with router dev tools how the router state looks like
harsh-harlequinOPβ’2y ago
okay, what should I see ?
eastern-cyanβ’2y ago
does
params contain the correct value?
if yes, this is likely a problem how you use react-query
but really, you need to provide a complete example, otherwise it is just guessingharsh-harlequinOPβ’2y ago
Can I send a github link?
eastern-cyanβ’2y ago
if you have a minimal example that exhibits this problem, sure
harsh-harlequinOPβ’2y ago
where it is located ?
in context?
harsh-harlequinOPβ’2y ago

harsh-harlequinOPβ’2y ago
here I guess?
eastern-cyanβ’2y ago

eastern-cyanβ’2y ago
on the right
click on the match and then check the match details
harsh-harlequinOPβ’2y ago
I don't have iot wtf
ok
i have it now
harsh-harlequinOPβ’2y ago

harsh-harlequinOPβ’2y ago
I don't have it
eastern-cyanβ’2y ago
click on "product/1"
harsh-harlequinOPβ’2y ago
oh ok my bad sorry
harsh-harlequinOPβ’2y ago

harsh-harlequinOPβ’2y ago
okay so that
harsh-harlequinOPβ’2y ago

harsh-harlequinOPβ’2y ago
so the params seems ok
but the data isnt
eastern-cyanβ’2y ago
then check the react-query devtools
harsh-harlequinOPβ’2y ago
I use tanstack query
eastern-cyanβ’2y ago
hm?
eastern-cyanβ’2y ago
Devtools | TanStack Query Docs
Wave your hands in the air and shout hooray because React Query comes with dedicated devtools! Γ°ΕΈΒ₯Β³
When you begin your React Query journey, you'll want these devtools by your side. They help visualize all of the inner workings of React Query and will likely save you hours of debugging if you find yourself in a pinch!
harsh-harlequinOPβ’2y ago
npm i @tanstack/react-query-devtools
yup
harsh-harlequinOPβ’2y ago

harsh-harlequinOPβ’2y ago
the id is never updated
(in query)
I think this implementation isn't good:
And I call it there:
eastern-cyanβ’2y ago
yes, the query key must contain the
productIdharsh-harlequinOPβ’2y ago
queryKey: ['product_by_id', productId],
just like that ?eastern-cyanβ’2y ago
for example yes
harsh-harlequinOPβ’2y ago
yeah it works!
eastern-cyanβ’2y ago
as I suspected π
harsh-harlequinOPβ’2y ago
you'r great !
there is a channel to ask for react question in general?
eastern-cyanβ’2y ago
harsh-harlequinOPβ’2y ago
yeah react
eastern-cyanβ’2y ago
not on this discord server
harsh-harlequinOPβ’2y ago
okay π
eastern-cyanβ’2y ago