Skip to content

React Query v5 beta - #1705

Merged
david-crespo merged 4 commits into
mainfrom
rq-v5
Jul 27, 2023
Merged

david-crespo merged 4 commits into
mainfrom
rq-v5

Conversation

@david-crespo

@david-crespo david-crespo commented Jul 27, 2023 •

Copy link
Copy Markdown
Collaborator

The beta looks very solid — they've been doing alphas for a very long time. There aren't major direct feature improvements that we need over v4, but there are big internal simplifications that reduce the surface area for bugs. There are also improvements to the types due to the single signature for useQuery (see tweet from maintainer). I also want to get on v5 before making any big changes to our data fetching while working on #1703.

The key changes for us are:

  • useQuery and friends take { queryKey: ..., queryFn: ... } as part of the options object instead of taking the key and function as positional args (docs)
  • isLoading becomes isPending (docs)
  • keepPreviousData: true becomes placeholderData: (x) => x (docs)
  • useErrorBoundary becomes throwOnError (docs)

https://tanstack.com/query/v5/docs/react/guides/migrating-to-v5

Marking as draft because I still want to do some cleanup. There are some ridiculous types in the API hooks.

@vercel

vercel Bot commented Jul 27, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Jul 27, 2023 4:37pm

Comment thread libs/api/hooks.ts
} from '@tanstack/react-query'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
// TODO: either do this differently or get them to export this type
import type { UndefinedInitialDataOptions } from 'node_modules/@tanstack/react-query/build/modern/queryOptions'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

working on this, otherwise I think we're ok

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll see if they accept adding the export or give me a tip about a different way to do it: TanStack/query#5794

Comment thread libs/api/hooks.ts

/** Result that includes both success and error so it can be cached by RQ */
type ErrorsAllowed<T, E> = { type: 'success'; data: T } | { type: 'error'; data: E }

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this continues to work and I understand it because I wrote it, but it's ridiculous. I'm always mulling over how we might avoid a lot of the complication here by generating more code in oxide.ts instead.

This branch was successfully deployed

1 active deployment
Preview — d4e69805 Deployed Jul 27, 2023 by vercel[bot]
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

Successfully merging this pull request may close these issues.

1 participant