-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[🐞] V2: Bug when signal of useComputed$
is used in useTask$
or useVisibleTask$
#7213
Comments
Analysis: Expected output:
The computed should execute on client, because in v2 it is lazy and on the server it was not needed. Workaround: useVisibleTask$(async () => {
console.log(text.value); // <-- read the computed value first
console.log('useVisibleTask$: Do stuff with text...'); <-- then execute the rest
}); We should probably think how to solve this anyway |
Thanks Michał! There is a similar "bug" with |
Yes, I think you are right. My bad. |
Which component is affected?
Qwik Runtime
Describe the bug
When a
useComputed$
signal is read inuseVisibleTask$
, the task is executed twice (or multiple times if multipleuseComputed$
are used). Also,useComputed$
is unnecessarily re-executed afterwards.Reproduction
https://stackblitz.com/edit/github-o2f6fj9n-meq2plo7?file=src%2Froutes%2Findex.tsx
Steps to reproduce
Now you should see this in the console:
The expected output would be:
This is because
useComputed$
should only run once on the sever anduseVisibleTask$
should only run once in the browser. A similar bug exists when usinguseTask$
.System Info
Additional Information
No response
The text was updated successfully, but these errors were encountered: