parent
918b37935a
commit
2347e3e47e
4 changed files with 14 additions and 9 deletions
|
@ -19,7 +19,7 @@ export type LoadComponentsReturnType = {
|
|||
params: any
|
||||
}) => {
|
||||
props: any
|
||||
revalidate: number | false
|
||||
revalidate?: number | boolean
|
||||
}
|
||||
unstable_getStaticPaths?: () => void
|
||||
buildManifest?: any
|
||||
|
|
|
@ -156,7 +156,7 @@ type RenderOpts = {
|
|||
params: any | undefined
|
||||
}) => {
|
||||
props: any
|
||||
revalidate: number | false
|
||||
revalidate?: number | boolean
|
||||
}
|
||||
unstable_getStaticPaths?: () => void
|
||||
}
|
||||
|
@ -458,14 +458,14 @@ export async function renderToHTML(
|
|||
`\nTo only run getStaticProps at build-time and not revalidate at runtime, you can set \`revalidate\` to \`false\`!`
|
||||
)
|
||||
}
|
||||
} else if (data.revalidate === false) {
|
||||
// `false` is an allowed behavior. We'll catch `revalidate: true` and
|
||||
// fall into our default behavior.
|
||||
} else {
|
||||
// By default, we revalidate after 1 second. This value is optimal for
|
||||
} else if (data.revalidate === true) {
|
||||
// When enabled, revalidate after 1 second. This value is optimal for
|
||||
// the most up-to-date page possible, but without a 1-to-1
|
||||
// request-refresh ratio.
|
||||
data.revalidate = 1
|
||||
} else {
|
||||
// By default, we never revalidate.
|
||||
data.revalidate = false
|
||||
}
|
||||
|
||||
props.pageProps = data.props
|
||||
|
|
|
@ -19,7 +19,7 @@ export async function unstable_getStaticProps() {
|
|||
world: text,
|
||||
time: new Date().getTime(),
|
||||
},
|
||||
revalidate: 1,
|
||||
revalidate: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ const expectedManifestRoutes = () => ({
|
|||
},
|
||||
'/default-revalidate': {
|
||||
dataRoute: `/_next/data/${buildId}/default-revalidate.json`,
|
||||
initialRevalidateSeconds: 1,
|
||||
initialRevalidateSeconds: false,
|
||||
srcRoute: null,
|
||||
},
|
||||
'/something': {
|
||||
|
@ -114,12 +114,17 @@ const navigateTest = () => {
|
|||
'/blog/post-1/comment-1',
|
||||
]
|
||||
|
||||
await waitFor(2500)
|
||||
|
||||
await Promise.all(toBuild.map(pg => renderViaHTTP(appPort, pg)))
|
||||
|
||||
const browser = await webdriver(appPort, '/')
|
||||
let text = await browser.elementByCss('p').text()
|
||||
expect(text).toMatch(/hello.*?world/)
|
||||
|
||||
// hydration
|
||||
await waitFor(2500)
|
||||
|
||||
// go to /another
|
||||
await browser.elementByCss('#another').click()
|
||||
await browser.waitForElementByCss('#home')
|
||||
|
|
Loading…
Reference in a new issue