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

Question: Can I use <Query> or only hooks? #112

Closed
justinpincar opened this issue Oct 10, 2023 · 2 comments
Closed

Question: Can I use <Query> or only hooks? #112

justinpincar opened this issue Oct 10, 2023 · 2 comments

Comments

@justinpincar
Copy link

The readme of https://github.com/apollographql/apollo-client-nextjs says:

You can import the following Apollo Client hooks from "@apollo/experimental-nextjs-app-support/ssr" in your client components (make sure you are not importing these hooks from @apollo/client as this package wraps and re-exports them to support streaming SSR):

  • useQuery
  • useSuspenseQuery
  • useBackgroundQuery
  • useReadQuery
  • useFragment

Just wanted to clarify - am I limited to useQuery and the hooks listed, or can I still use the component versions too? Is it ok to mix/match or do I need to refactor my code to only do useQuery?

Thanks!

@phryneas
Copy link
Member

Only the hooks.

At this point, we consider the old components as legacy and will probably be removing them in a future version of Apollo Client, so it's a good idea to slowly migrate away from them anyways.

You already see this with hooks like useSuspenseQuery that don't have a corresponding Component - many modern React suspense features will be impossible to use without hooks, (e.g. the useTransition hook is very important with useSuspenseQuery), so you'll be losing out on modern React features if you're not using hooks.

@justinpincar
Copy link
Author

Gotcha, thanks for the heads up.

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