qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[🐞] If Signal is used by useTask$ it doesn't re-render should it work that way?

Open notcod opened this issue 1 year ago • 6 comments

Which component is affected?

Qwik Runtime

Describe the bug

On button clicking I set value of Signal to true, If Signal is true, I want to hide button until task is completed, it works with useVisualTask$ but doesn't work with useTask$, am I doing something wrong?

check out reproduction url https://stackblitz.com/edit/qwik-starter-sbzklc?file=src%2Froutes%2Findex.tsx,package.json

export const ServerTask = component$(() => {
  const page = useSignal(1);
  const loading = useSignal(false);
  useTask$(async ({ track }) => {
    track(page);
    if (loading.value) {
      await new Promise((r) => setTimeout(r, 1000));
      loading.value = false;
    }
  });
  const increase = $(async () => {
    page.value++;
    loading.value = true;
  });
  return (
    <>
      {page.value} - {loading.value ? 'loading...' : 'loaded!'}
      <br />
      {!loading.value && <input type="submit" onClick$={increase} />}
    </>
  );
});

Reproduction

https://stackblitz.com/edit/qwik-starter-sbzklc?file=src%2Froutes%2Findex.tsx,package.json

Steps to reproduce

No response

System Info

npx envinfo --system --npmPackages '{vite,undici,@builder.io/*}' --binaries --browsers

Additional Information

No response

notcod avatar Feb 19 '24 11:02 notcod