mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This PR corrects the data fetching behavior for optional root routes. --- Fixes #14923
22 lines
429 B
JavaScript
22 lines
429 B
JavaScript
import { useRouter } from 'next/router'
|
|
|
|
export const getStaticPaths = () => ({
|
|
paths: [],
|
|
fallback: true,
|
|
})
|
|
|
|
export const getStaticProps = ({ params }) => ({ props: { params } })
|
|
|
|
export default function Page({ params }) {
|
|
const r = useRouter()
|
|
if (r.isFallback) {
|
|
return <div>loading</div>
|
|
}
|
|
|
|
return (
|
|
<div id="success">
|
|
{params.optionalName ? params.optionalName.join(',') : 'yay'}
|
|
</div>
|
|
)
|
|
}
|