-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
using context
inside of useQuery
falls into an infinite loop
#507
Comments
Hey @macy Thanks for the error report, this is intended. We advice using useQuery({ query: MyQuery, variables: { someId }, context: React.useMemo(() => ({}), []) }); Should do the trick. |
Thanks @JoviDeCroock -- I don't know if that was clear in the docs after a quick glance, I'd be happy to make a PR, thoughts? |
That would be awesome, we're trying to be as clear as we can in our documentation but an outside view is most often the best to show us these oversights. That contribution would be more than welcome! |
🔥 Will do! Thank you for the awesome work in this library! |
I've created a PR that updates the missing info in the docs: #1800 |
Describe the bug
useQuery
will fall into an indefinite render loop if you passcontext
akaPartial<OperationContext>
as a parameter.Steps to reproduce
Create a
useQuery
hook and passcontext
, e.g.Expected behavior
useQuery is only called once.
Actual behavior
useQuery falls into an infinite loop.
Additional context
I think using
context
is valuable because it's a great way to pass in an auth token as a header if you don't have access to an auth token outside of a component render context.The text was updated successfully, but these errors were encountered: