4e0b40145d
This fixes invalid initial route params in development mode and serverless production mode. It also adds tests to ensure these values are correct in development, production, and serverless mode. x-ref: https://github.com/vercel/next.js/pull/16084 Fixes: https://github.com/vercel/next.js/issues/16481 Fixes: https://github.com/vercel/next.js/issues/16482
34 lines
608 B
JavaScript
34 lines
608 B
JavaScript
import { useRouter } from 'next/router'
|
|
|
|
export const getStaticProps = () => {
|
|
return {
|
|
props: {
|
|
world: 'world',
|
|
},
|
|
}
|
|
}
|
|
|
|
export const getStaticPaths = () => {
|
|
return {
|
|
paths: [],
|
|
fallback: true,
|
|
}
|
|
}
|
|
|
|
export default function Page({ world }) {
|
|
const router = useRouter()
|
|
|
|
if (typeof window !== 'undefined' && !window.setInitialSlug) {
|
|
window.setInitialSlug = true
|
|
window.initialSlug = router.query.slug
|
|
}
|
|
|
|
if (router.isFallback) return 'Loading...'
|
|
|
|
return (
|
|
<>
|
|
<p>hello {world}</p>
|
|
<p id="query">{JSON.stringify(router.query)}</p>
|
|
</>
|
|
)
|
|
}
|