Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import { LinkAccordion } from '../../components/link-accordion'
|
|
|
|
export default function RefetchOnNewBaseTreeLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<>
|
|
<div style={{ backgroundColor: 'lightgray', padding: '1rem' }}>
|
|
<p>
|
|
This demonstrates what happens when a link is prefetched using{' '}
|
|
<code>{'prefetch={true}'}</code> and the URL changes. Next.js should
|
|
re-prefetch the link in case the delta between the base tree and the
|
|
target tree has changed.
|
|
</p>
|
|
<p>
|
|
Everything in this gray section is part of a shared layout. The links
|
|
below are prefetched using <code>{'prefetch={true}'}</code>. If the
|
|
first loaded page is "/refetch-on-new-base-tree/a", the prefetch for
|
|
this link will be empty, because there's no delta between the base
|
|
tree and the target tree.
|
|
</p>
|
|
<p>
|
|
However, if you then navigate to page B, we should re-prefetch the
|
|
link to A, because the delta between the base tree and the target tree
|
|
is now different.
|
|
</p>
|
|
<p>Test steps:</p>
|
|
<ul>
|
|
<li>Load "/refetch-on-new-base-tree/a" in the browser.</li>
|
|
<li>
|
|
Click the checkboxes to reveal the links. (These exist so the e2e
|
|
test can control the timing of the prefetch.)
|
|
</li>
|
|
<li>
|
|
Observe that the prefetch for page A is empty, i.e. the string "Page
|
|
A content" should not appear anywhere in the response.
|
|
</li>
|
|
<li>Click the link to page B to navigate away.</li>
|
|
<li>
|
|
Check the network tab to confirm that a new prefetch for page A was
|
|
requested.
|
|
</li>
|
|
<li>Click the link to page A</li>
|
|
<li>
|
|
Observe that no new request was made when navigating to page A,
|
|
because it was fully prefetched.
|
|
</li>
|
|
</ul>
|
|
<LinkAccordion prefetch={true} href="/refetch-on-new-base-tree/a">
|
|
Page A
|
|
</LinkAccordion>
|
|
<LinkAccordion prefetch={true} href="/refetch-on-new-base-tree/b">
|
|
Page B
|
|
</LinkAccordion>
|
|
</div>
|
|
<div>{children}</div>
|
|
</>
|
|
)
|
|
}
|