A shared layout that renders from the URL holds the new page for one more round trip

Aperta
#9,516 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start with e2e/preloader-e2e/tests/navigation.e2e.ts and the failing “layout that renders from the URL” case; run the two commands listed in the issue to reproduce it. Then trace how shared layouts and URL dependent components are handled during navigation, using #9517 and #9435 for context. Done means the new page appears in 2 round trips.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

preloader V2

Part of #9434.

On a navigation between two pages with the same layout, the router stops preloading that layout's chunks (#9517, on top of #9515). That is right for a layout that stays as it is. But a component in the shared layout that picks what to render from the URL must run again when the URL changes:

export const UrlBanner = component$(() => {
  const loc = useLocation();
  if (loc.url.pathname.endsWith('/b/')) {
    return <strong>on page b</strong>;
  }
  return <p>elsewhere</p>;
});

Its chunk is only requested at that moment, one round trip after the new page's chunks, and Qwik holds the whole update until it arrives. The new page shows in 3 round trips, not 2.

A read written straight in the JSX (<p>{loc.url.pathname}</p>) is not affected: it updates without the component's code.

Why

The click can't know what depends on the URL. That is in the page's serialized state, not in the bundle graph. It is the same gap as #9435.

Pinned by e2e/preloader-e2e/tests/navigation.e2e.ts:

  • layout that renders from the URL › the new page shows in 3 round trips, over the cap of 2 (count over the cap)

Run it

pnpm build.core
pnpm test.e2e.preloader -g "layout that renders from the URL"

Done when the new page shows in 2 round trips.

Lingua principale
TypeScript
Stelle
22.1k
Fork
1.4k
Merge medio
1g 13h
PR unite (30g)
159

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di QwikDev/qwik

Tutte le issue di QwikDev/qwik

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.