Removing keepPreviousData and using placeholderData
The keepPreviousData
option and the isPreviousData
flags have been removed. This is because they did almost the same task as the placeholderData
option and the isPlaceholderData
flag.
So that placeholderData
can fully do exactly the same thing as keepPreviousData
, the previous query data was added as an argument to the placeholderData
function. This now means that by leveraging the keepPreviousData
custom function from React Query, useQuery
will allow placeholderData
to work the same way as keepPreviousData
did previously.
Let us see how our PaginatedQuery
code changes in v5:
import { useQuery, keepPreviousData } from "@tanstack/react-query"; ... const PaginatedQuery = () => { ... const { isPending, isError, error, data, isFetching, isPlaceholderData } = useQuery({ queryKey: userKeys.paginated(page), &...