mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Provides a `revalidateReason` argument to `getStaticProps` ("stale" |
"on-demand" | "build").
- Build indicates it was run at build time
- On-demand indicates it was run as a side effect of [on-demand
revalidation](https://nextjs.org/docs/pages/building-your-application/data-fetching/incremental-static-regeneration#on-demand-revalidation)
- Stale indicates the resource was considered stale (either due to being
in dev mode, or an expired revalidate period)
This will allow changing behavior based on the context in which it's
called.
Closes NEXT-1900
18 lines
320 B
TypeScript
18 lines
320 B
TypeScript
import React from 'react'
|
|
|
|
export async function getStaticProps({ params, revalidateReason }) {
|
|
console.log(
|
|
'revalidate-reason/pages/index.tsx revalidateReason:',
|
|
revalidateReason
|
|
)
|
|
return {
|
|
props: {
|
|
hello: 'world',
|
|
},
|
|
}
|
|
}
|
|
|
|
export default ({ hello }) => {
|
|
return <p>hello: {hello}</p>
|
|
}
|