Skip to content
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

setSize on useSWRInfinite when page index is null output object as data instead of undefined #1286

Closed
mhsattarian opened this issue Jul 11, 2021 · 1 comment

Comments

@mhsattarian
Copy link

Bug report

Description / Observed Behavior

When page index (first parameter of useSWRInfinite) is null and setSize method is called, data instead of being undefined (as expected) becomes an object as below:

{
	data: undefined,
    "force": false
}

Expected Behavior

It should output undefined as data.

Repro Steps / Code Example

use the swr-infinite CodeSandbox from the docs and change version to 0.5.6.
or use this CodeSandbox.

Additional Context

this was ok in version 0.3.0 as I tested in swr-infinite CodeSandbox, but it's not now in 0.5.6.

I hadn't investigated the problem, but I think there might be an issue with this line:

let pageData = cache.get(pageKey)

I guess it should be like this?:

const { data: pageData, force } = cache.get(pageKey)
@shuding
Copy link
Member

shuding commented Jul 18, 2021

This bug should have been fixed in the latest beta, I cannot reproduce it here: https://codesandbox.io/s/swr-infinite-forked-mx7wc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants