Skip to content

Commit

Permalink
[Docs] Update with-loading example (#39646)
Browse files Browse the repository at this point in the history
Changelog

Updated dependencies
Migrated to Typescript
Use CSS from npm module

Documentation / Examples

 Make sure the linting passes by running pnpm lint
 The examples guidelines are followed from our contributing doc
  • Loading branch information
HaNdTriX committed Aug 16, 2022
1 parent 6fd2a7f commit 7a93093
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 95 deletions.
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"]
}

0 comments on commit 7a93093

Please sign in to comment.