-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ee09d20
Showing
26 changed files
with
2,809 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
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,36 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
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 @@ | ||
registry "https://registry.npmjs.org/" |
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,34 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|
||
## Getting Started | ||
|
||
First, run the development server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file. | ||
|
||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`. | ||
|
||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. | ||
|
||
## Learn More | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
|
||
## Deploy on Vercel | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. |
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,16 @@ | ||
const Loading = () => { | ||
return ( | ||
<div className="lds-roller"> | ||
<div></div> | ||
<div></div> | ||
<div></div> | ||
<div></div> | ||
<div></div> | ||
<div></div> | ||
<div></div> | ||
<div></div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Loading; |
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,16 @@ | ||
import durations from "../../../../util/durations"; | ||
|
||
export const getServerSideProps = async (context) => { | ||
const { duration } = context.params; | ||
|
||
// artificial delay | ||
await new Promise((resolve) => setTimeout(resolve, durations[duration])); | ||
|
||
return { | ||
props: { wait: durations[duration] }, | ||
}; | ||
}; | ||
|
||
export default function Page({ children, wait }) { | ||
return <p> Waited {wait / 1000} seconds</p>; | ||
} |
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,10 @@ | ||
const HappyWithLoadingLayout = ({ children }) => { | ||
return ( | ||
<> | ||
<p>Happy Path With Loading</p> | ||
<div style={{ textAlign: "center" }}>{children}</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default HappyWithLoadingLayout; |
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,5 @@ | ||
const HappyPage = ({ children }) => { | ||
return <p>Explore the Happy Path!</p>; | ||
}; | ||
|
||
export default HappyPage; |
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,28 @@ | ||
import SubNav from "../../components/sub-nav.client"; | ||
|
||
const ExamplesLayout = ({ children }) => { | ||
return ( | ||
<> | ||
<div | ||
style={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
alignItems: "center", | ||
}} | ||
> | ||
<SubNav /> | ||
<div | ||
style={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
alignItems: "center", | ||
}} | ||
> | ||
{children} | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default ExamplesLayout; |
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,5 @@ | ||
const Loading = () => { | ||
<> Loading</>; | ||
}; | ||
|
||
export default Loading; |
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,16 @@ | ||
import durations from "../../../../util/durations"; | ||
|
||
export const getServerSideProps = async (context) => { | ||
const { duration } = context.params; | ||
|
||
// artificial delay | ||
await new Promise((resolve) => setTimeout(resolve, durations[duration])); | ||
|
||
return { | ||
props: { wait: durations[duration] }, | ||
}; | ||
}; | ||
|
||
export default function Page({ children, wait }) { | ||
return <p> Waited {wait / 1000} seconds</p>; | ||
} |
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,10 @@ | ||
const SadLayout = ({ children }) => { | ||
return ( | ||
<> | ||
<p>Sad Path</p> | ||
<div style={{ textAlign: "center" }}>{children}</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default SadLayout; |
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,5 @@ | ||
const SadPage = ({ children }) => { | ||
return <p>Explore the Sad Path!</p>; | ||
}; | ||
|
||
export default SadPage; |
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,22 @@ | ||
import React from "react"; | ||
import "../styles/globals.css"; | ||
import TopNav from "../components/nav.client"; | ||
|
||
export default function RootLayout({ children }) { | ||
return ( | ||
<html> | ||
<head> | ||
<title>RSC Layout Streaming MVR</title> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
<div> | ||
<TopNav /> | ||
</div> | ||
<div style={{ padding: "20px 100px" }}>{children}</div> | ||
</div> | ||
</body> | ||
</html> | ||
); | ||
} |
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,26 @@ | ||
export default function Page() { | ||
return ( | ||
<div style={{ padding: "20px" }}> | ||
<h3>RSC / Layouts Loading Examples </h3> | ||
<p> Description </p> | ||
<p> | ||
Each path has nested layouts which use artificial delays to simulate a | ||
server component waiting for data fetch. Each path includes multiple | ||
delay options for 1, 5 and 10 seconds. | ||
</p> | ||
<p>Happy Path</p> | ||
<ul> | ||
<li>loading.js used</li> | ||
<li>Initial page load streams content</li> | ||
</ul> | ||
<p>Sad Path</p> | ||
<ul> | ||
<li>loading.js not used</li> | ||
<li> | ||
Initial page load waits for delay, does not stream rest of page first | ||
</li> | ||
<li>No client or server side logs indicating incorrect setup</li> | ||
</ul> | ||
</div> | ||
); | ||
} |
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,19 @@ | ||
import Link from "next/link"; | ||
|
||
const Nav = () => ( | ||
<> | ||
<div style={{ display: "flex", justifyContent: "center" }}> | ||
<div style={{ display: "flex", flexDirection: "column" }}> | ||
<h2 style={{ textAlign: "center" }}>RSC Streaming Loading MVR</h2> | ||
|
||
<div style={{ display: "flex", flexDirection: "row" }}> | ||
<Link href="/">Home</Link> | ||
<Link href="/happy">Happy Loading Path</Link> | ||
<Link href="/sad">Sad Path</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
|
||
export default Nav; |
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,34 @@ | ||
import Link from "next/link"; | ||
import durations from "../util/durations"; | ||
import { useState } from "react"; | ||
import { usePathname } from "next/dist/client/components/hooks-client"; | ||
|
||
const SubNav = () => { | ||
const [count, setCount] = useState(0); | ||
|
||
const pathname = usePathname(); | ||
|
||
// this is trash but I'm too lazy to fix it | ||
const basePath = pathname.includes("happy") ? "happy" : "sad"; | ||
|
||
return ( | ||
<> | ||
<div style={{ display: "flex", flexDirection: "row" }}> | ||
{Object.keys(durations).map((duration) => ( | ||
<Link | ||
key={duration} | ||
className="subnav" | ||
href={`/${basePath}/${duration}`} | ||
> | ||
{duration} | ||
</Link> | ||
))} | ||
<button onClick={() => setCount((curCount) => curCount + 1)}> | ||
Clicks: {count} | ||
</button> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default SubNav; |
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,24 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
swcMinify: true, | ||
experimental: { | ||
// Required: | ||
appDir: true, | ||
serverComponents: true, | ||
// Recommended for new `<Link>` and `<Image>` behavior | ||
// Enables `<Link>` without `<a>`. When migrating an existing app use the codemod as outlined here: https://github.com/vercel/next.js/pull/36436 | ||
newNextLinkBehavior: true, | ||
// Enables `next/future/image` | ||
images: { | ||
allowFutureImage: true, | ||
}, | ||
// Recommended, will be the default in the next major version: | ||
// Enable browserslist handling, which is required for legacyBrowsers: false | ||
browsersListForSwc: true, | ||
// Change the default compilation output to ESModules compatible browsers | ||
legacyBrowsers: false, | ||
}, | ||
}; | ||
|
||
module.exports = nextConfig; |
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,24 @@ | ||
{ | ||
"name": "rsc-next-loading-mvr", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint" | ||
}, | ||
"dependencies": { | ||
"@emotion/react": "^11.10.4", | ||
"@emotion/styled": "^11.10.4", | ||
"@fontsource/roboto": "^4.5.8", | ||
"@mui/material": "^5.10.3", | ||
"next": "^12.2.6-canary.8", | ||
"react": "^0.0.0-experimental-9ff738f53-20220826", | ||
"react-dom": "^0.0.0-experimental-9ff738f53-20220826" | ||
}, | ||
"devDependencies": { | ||
"eslint": "8.23.0", | ||
"eslint-config-next": "12.2.5" | ||
} | ||
} |
Empty file.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.