-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move changes into new ppr test suite
- Loading branch information
Showing
10 changed files
with
310 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
export default () => { | ||
return 'Static' | ||
return ( | ||
<dl> | ||
<dt>Pathname</dt> | ||
<dd data-pathname="/static">/static</dd> | ||
</dl> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
import React from 'react' | ||
import { headers } from 'next/headers' | ||
import React, { use } from 'react' | ||
import * as next from 'next/headers' | ||
|
||
export const Dynamic = ({ pathname, fallback }) => { | ||
if (fallback) { | ||
return <div>Dynamic Loading...</div> | ||
} | ||
|
||
const headers = next.headers() | ||
const messages = [] | ||
const names = ['x-test-input', 'user-agent'] | ||
const list = headers() | ||
for (const name of ['x-test-input', 'user-agent']) { | ||
messages.push({ name, value: headers.get(name) }) | ||
} | ||
|
||
for (const name of names) { | ||
messages.push({ name, value: list.get(name) }) | ||
const delay = headers.get('x-delay') | ||
if (delay) { | ||
use(new Promise((resolve) => setTimeout(resolve, parseInt(delay, 10)))) | ||
} | ||
|
||
return ( | ||
<div id="needle"> | ||
<dl> | ||
{pathname && ( | ||
<> | ||
<dt>Pathname</dt> | ||
<dd>{pathname}</dd> | ||
</> | ||
)} | ||
{messages.map(({ name, value }) => ( | ||
<React.Fragment key={name}> | ||
<dt> | ||
Header: <code>{name}</code> | ||
</dt> | ||
<dd>{value ?? `MISSING:${name.toUpperCase()}`}</dd> | ||
</React.Fragment> | ||
))} | ||
</dl> | ||
</div> | ||
<dl> | ||
{pathname && ( | ||
<> | ||
<dt>Pathname</dt> | ||
<dd data-pathname={pathname}>{pathname}</dd> | ||
</> | ||
)} | ||
{messages.map(({ name, value }) => ( | ||
<React.Fragment key={name}> | ||
<dt> | ||
Header: <code>{name}</code> | ||
</dt> | ||
<dd>{value ?? `MISSING:${name.toUpperCase()}`}</dd> | ||
</React.Fragment> | ||
))} | ||
</dl> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
import { Links } from './links' | ||
|
||
export const Layout = ({ children }) => { | ||
return ( | ||
<> | ||
<h1>Partial Prerendering</h1> | ||
<p> | ||
Below are links that are associated with different pages that all will | ||
partially prerender | ||
</p> | ||
<aside> | ||
<Links /> | ||
</aside> | ||
<main>{children}</main> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react' | ||
import { Layout } from '../components/layout' | ||
|
||
export default () => { | ||
return ( | ||
<Layout> | ||
<dl> | ||
<dt>Pathname</dt> | ||
<dd data-pathname="/pages">/pages</dd> | ||
</dl> | ||
</Layout> | ||
) | ||
} |
Oops, something went wrong.