dannyfranca / qwik-router

A SPA-like router for Qwik.
MIT License
19 stars 1 forks source link

[🐞] useVisibleTask$ called twice #6

Closed gioboa closed 6 months ago

gioboa commented 9 months ago

Which component is affected?

Qwik Runtime

Describe the bug

I cloned your starter git clone https://github.com/dannyfranca/qwik-router.git and I added useVisibleTask$ in the Route1 component here

useVisibleTask$(() => {
  console.log('useVisibleTask');
});

and the useVisibleTask$ called twice

Reproduction

-

Steps to reproduce

-

Additional Information

to avoid this problem I can create my own useVisibleTask$ wrapper

dannyfranca commented 7 months ago

Thanks for the feedback, @gioboa. I have been busy, I'll look into it this week.

dannyfranca commented 7 months ago

@gioboa, in this case, this is the expected behaviour. Each Router component has its context and its parameters. If you notice, the Route1 component belongs to the two routers in the example, which is why the useVisibleTask$ is executed twice. Executing one, would overwrite the other Router component's behaviour.

Given that, tell me if you would expect a different behaviour and why.

gioboa commented 6 months ago

I see, in the meantime I solved my problem with a ternary { route === 'A' ? <CmpA /> : <CmpB /> } I will give another try to the lib. Thanks for your work 👍