Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust return value #9712

Merged
merged 4 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/next-server/server/load-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type LoadComponentsReturnType = {
params: any
}) => {
props: any
revalidate: number | false
revalidate?: number | boolean
}
unstable_getStaticPaths?: () => void
buildManifest?: any
Expand Down
12 changes: 6 additions & 6 deletions packages/next/next-server/server/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ type RenderOpts = {
params: any | undefined
}) => {
props: any
revalidate: number | false
revalidate?: number | boolean
}
unstable_getStaticPaths?: () => void
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/integration/prerender/pages/another/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function unstable_getStaticProps() {
world: text,
time: new Date().getTime(),
},
revalidate: 1,
revalidate: true,
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/integration/prerender/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const expectedManifestRoutes = () => ({
},
'/default-revalidate': {
dataRoute: `/_next/data/${buildId}/default-revalidate.json`,
initialRevalidateSeconds: 1,
initialRevalidateSeconds: false,
srcRoute: null,
},
'/something': {
Expand Down