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

react-query #166

Open
coryhouse opened this issue Mar 9, 2023 · 3 comments
Open

react-query #166

coryhouse opened this issue Mar 9, 2023 · 3 comments

Comments

@coryhouse
Copy link
Owner

coryhouse commented Mar 9, 2023

Why you want react-query - Long list of things that are easy to screw up in useEffect

Configure error boundary at root

Handle background query errors separately

Group reads and writes together in a custom hook

Check both isLoading and isError to narrow data. If you only check one, data may be undefined. If you're using useErrorBoundary, then you can use a pattern like this: create custom wrappers by hand.

You might not need RQ in Next if you're using RSC

Use Orval to generate react-query calls from an OpenAPI spec.

Strongly typed keys

https://www.thisdot.co/blog/common-patterns-and-nuances-using-react-query/

Use setQueryData to pre-populate the detail page cache. Now the detail page loads immediately.

@vltansky
Copy link

Consider also https://www.zodios.org/ with https://github.com/astahmer/openapi-zod-client to generate react-query calls from OpenAPI specs.

@araphiel
Copy link

If I don't need Zod, I pair react-query with https://openapi-ts.pages.dev/openapi-fetch

@vltansky
Copy link

In addition to api client zodios generates react query hooks

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

3 participants