Skip to content

keepPreviousData does not preserve data #1002

Closed

Description

@andyvanhelsing

Setting keepPreviousData option to true does not preserve previous stale data when the query key changes but before refetch is called, as described in #419. There have been some API changes from v1 to v2 so it is possible that this is intentional but not well documented. Sample code:

const [dateRange, setDateRange] = React.useState([today, today]);
    const {data, latestData, resolvedData, error, refetch, isFetching} = usePaginatedQuery(
        [dateRange[0], dateRange[1]], // should not refetch when date range changes
        searchFx,
        {enabled: false, keepPreviousData: true} // have tried with and without keepPreviousData
    );

// only search when the button is clicked
return <Button onClick={refetch}>Search</Button>

A similar configuration was working in v1.5.10

Activity

  1. boschni commented on Sep 12, 2020

    @boschni
    Contributor

    Could you provide a codebox? Added some additional tests but cannot seem to replicate the issue: #1003

  2. tannerlinsley commented on Sep 18, 2020

    @tannerlinsley
    Member

    I cannot replicate. Feel free to reopen with a codesandbox or test to illustrate the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions