Replies: 3 comments 2 replies
-
To clarify, there are workarounds for it by modifying the fetcher function, though it would be nice to have it supported out of the box |
Beta Was this translation helpful? Give feedback.
-
I'd do this instead: function usePagainatedUsers () {
const { data } = useSWRInfinite(...)
// we manually pick and concat the paginated data array
const users = useMemo(() =>
[].concat(...data.map(page => page.array)),
[data]
)
return users
} And use the The reason that this lib can't simply support Right now, it's better to leave the flexibility to the user IMO, until we have a better and more general idea. I'll move this issue to discussion. |
Beta Was this translation helpful? Give feedback.
-
Hi, i have similar issue, fot the thanks |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug report
👋, I'm using
useSWRInfinite
to build infinite scrolling and saw that it doesn't support arrays that are nested in an object.Description / Observed Behavior
For example, the API that I'm using does the following:
[api-url]/?page=1
[api-url]/?page=2
useSWRInfinite
tries to append these two objects, which doesn't work, instead, it should attempt to append array of request 2 to array of request 1. There seems to be no way to support this atm.Additional Context
SWR version:
0.3.0-beta.6
Beta Was this translation helpful? Give feedback.
All reactions