-
Notifications
You must be signed in to change notification settings - Fork 17
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
infinite loop occurs on v2 #501
Comments
Hi @mehm8128. Looking through your example, I see that you create the transport on every render. connect-query now takes into account the transport when generating keys so that's likely where it's breaking. There are a few ways to fix this:
Generally, I'd recommend the option 1, since there's no magic string, but it depends on if your transport needs some runtime data. In this example, I don't see anything that would indicate it needed access to runtime data so this is the best option. Option 2 on the other hand, can be used to define exactly what you want to key to be. This means that if you want to trigger queries when something about the transport changes, you need to make sure that |
Thank you so much!!! |
I realized there's another option if the static key method is a little restrictive: You can memoize the transport using |
I upgraded connect-query-es and peripheral connect tools to v2 referencing migration guide, but infinite loop occurs when we call unary method.
This is my minimal reproduction source code which I created based on the examples-es/nextjs.
https://github.com/mehm8128/connect-query-infinite-loop-repro
Please check it following the below procedures.
npm i
res
and the callinguseEffect
) inpages/index.tsx
(or you will not be able to see the page)npm run start
(you will fail to runnpm run build
, so usestart
command)aaa
text on the started page (http://localhost:3000 ) , revert the comment out you did in the third stepSorry if there is any my mistake, but thank you for checking my issue 🙏
The text was updated successfully, but these errors were encountered: