New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
data
is undefined
using reactive query
#17
Comments
data
is undefined
using reactive query
Can I know more about what service.playerList does under the hood? |
In the REPL for this issue I used a simple fetch with the same issue: https://svelte.dev/repl/40782b4783244075b8c58cffbcf9acd4?version=3.42.1. My |
THIS IS HUGE and prevent me from using |
I'm going to explore this after work. Thanks for the report. |
Having the same issue here with trying to get pagination to work. Given the following code in a svelte component: /** Item position to start at */
let offset = 0
/** Number of items to get */
let first = 10
$: ({ data: pageData } = useSWR(() => 'pageItems', {
fetcher: () => query('someItemList', { first, offset })
}))
$: console.log('page data', $pageData)
The same behaviour happens when not using a custom fetcher: {...}
$: ({ data: pageData } = useSWR(() => `api/someItemList?first=${first}&offset=${offset}`))
{...} |
@Terrahop You are simply rerunning useSWR reactivly with different parameters. Therefor data is initialized as undefined at the beginning of the new request as per docs. See:
So imho this is expected behaviour. The solution to this is either:
|
Ah got it thanks for clearing that up, I'll take a look at extending useSWR then. |
I'm facing this issue as well, which is preventing me from using useSWR, unfortunately. |
Using the below code it makes
data === undefined
. Why?REPL: https://svelte.dev/repl/40782b4783244075b8c58cffbcf9acd4?version=3.42.1.
The text was updated successfully, but these errors were encountered: