useSWRInfinite
, first update of key doesn't trigger the proper data fetching
#1776
Labels
useSWRInfinite
, first update of key doesn't trigger the proper data fetching
#1776
Bug report
Description / Observed Behavior
I have a use case of
useSWRInfinite
where I add filters (as query params) to my paginated request.I would require each change in filters to trigger a full revalidation of data.
Because my swr key changes when I change my filters, I expected I would require nothing else to implement the use case.
Surprisingly,
useSWRInfinite
, does not properly refetch data after changing query params in my key.It seems to happen consistently on the first key update.
Am I missing something here?
Expected Behavior
I expected that any update to the swr key would trigger data fetching.
Repro Steps / Code Example
I updated the demo sandbox (outdated) that you provide in your documentation.
https://codesandbox.io/s/swr-infinite-forked-uibdc?file=/src/App.js:718-729
Here's the surprising behaviour:
When changing a query param impacting
useSWRInfinite
-getKey
, the first occurrence does not consistently trigger an API callsimplescreenrecorder-2022-01-10_15.30.33.mp4
Additional Context
SWR version: 1.1.2
The text was updated successfully, but these errors were encountered: