rsnext/test/integration/fallback-route-params/pages/[slug].js
JJ Kasper 4e0b40145d
Correct initial fallback route param values (#16485)
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
2020-08-23 12:35:30 +00:00

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>
</>
)
}