Use useSWRInfinite in multiple locations #869
Unanswered
rinkstiekema
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Does It would be helpful if you have a CodeSandbox project to reproduce it. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to use data coming from useSWRInfinite in multiple locations. The first location would be at a central hook which prefetches data. The second location is the page where the data is actually used.
The hook which allows prefetching.
API
is a function which exposes many different endpoints.API.useData
looks like this:The second place where
Api.useData(id)
is used, is the actual page and is similar to the example found here.The behavior I am experiencing is that now the
index
argument in thegetKey
function is always 0, even when I usesetSize
from useSWRInfinite to set the size to any other number.Is this expected behavior? Am I missing something? Or is this a bug?
Thanks, hope anyone can help!
Beta Was this translation helpful? Give feedback.
All reactions