QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.83k stars 1.31k forks source link

[🐞] Navigating between nested routes with a `useLocation` causes an error: `element must be connected to the dom` #2751

Closed DustinJSilk closed 1 year ago

DustinJSilk commented 1 year ago

Which component is affected?

Qwik Runtime

Describe the bug

Using the useLocation hook in a parent layout file causes a breaking error to be thrown when navigating between pages multiple times.

Reproduction

https://github.com/DustinJSilk/qwik-brokenuse-location

Steps to reproduce

Install and run the linked repository Click the big purple button 4 times See an error in the console.

System Info

System:
    OS: macOS 12.0.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 485.49 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 7.13.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 109.0.5414.119
    Firefox: 109.0
    Safari: 15.1
  npmPackages:
    @builder.io/qwik: BuilderIO/qwik-build#main => 0.16.2 
    @builder.io/qwik-city: BuilderIO/qwik-city-build#main => 0.1.0-beta9 
    undici: 5.16.0 => 5.16.0 
    vite: 4.0.4 => 4.0.4

Additional Information

No response

DustinJSilk commented 1 year ago

Just wanted to give a friendly nudge to see if you’re able to squeeze in a fix for this any time soon? Thanks!! @manucorporat

MicroBenz commented 1 year ago

It still happens to me with these versions

"@builder.io/qwik": "0.20.1",
"@builder.io/qwik-city": "0.5.2",

It happens when I use useLocation() to get url.pathname for my navbar components to make an active link. It throws error when navigate to different page using Link