Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Update with-loading example #39646

Merged
merged 2 commits into from Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions examples/with-loading/package.json
Expand Up @@ -8,7 +8,13 @@
"dependencies": {
"next": "latest",
"nprogress": "^0.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "18.7.5",
"@types/nprogress": "0.2.0",
"@types/react": "18.0.17",
"typescript": "4.7.4"
}
}
@@ -1,17 +1,19 @@
import type { AppProps } from 'next/app'
import { useEffect } from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import NProgress from 'nprogress'
import '../public/nprogress.css'
import 'nprogress/nprogress.css'

export default function App({ Component, pageProps }) {
export default function App({ Component, pageProps }: AppProps) {
const router = useRouter()

useEffect(() => {
const handleStart = (url) => {
const handleStart = (url: string) => {
console.log(`Loading: ${url}`)
NProgress.start()
}

const handleStop = () => {
NProgress.done()
}
Expand Down
@@ -1,10 +1,10 @@
const AboutPage = () => <p>This is about Next.js!</p>

export async function getServerSideProps() {
await new Promise((resolve) => {
setTimeout(resolve, 500)
})
return { props: {} }
}

export default AboutPage
export default function AboutPage() {
return <p>This is about Next.js!</p>
}
@@ -1,10 +1,10 @@
const ForeverPage = () => <p>This page was rendered for a while!</p>

export async function getServerSideProps() {
await new Promise((resolve) => {
setTimeout(resolve, 3000)
})
return { props: {} }
}

export default ForeverPage
export default function ForeverPage() {
return <p>This page was rendered for a while!</p>
}
3 changes: 0 additions & 3 deletions examples/with-loading/pages/index.js

This file was deleted.

3 changes: 3 additions & 0 deletions examples/with-loading/pages/index.tsx
@@ -0,0 +1,3 @@
export default function IndexPage() {
return <p>Hello Next.js!</p>
}
81 changes: 0 additions & 81 deletions examples/with-loading/public/nprogress.css

This file was deleted.

20 changes: 20 additions & 0 deletions examples/with-loading/tsconfig.json
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}