ISR Still Broken in 13.5.4?
Unanswered
Southern African anchovy posted this in #help-forum
Southern African anchovyOP
Am I missing something here? I expect this component to render a new timestamp every 10 seconds in a production build however after the initial 2 renders (one build and one request), it does not update.
export const revalidate = 10
const wait = async (ms: number) =>
new Promise((resolve) => {
setTimeout(resolve, ms)
})
const getServerTime = async () => {
await wait(2000)
return new Date().toLocaleTimeString()
}
export default async function ISRTestPage() {
const serverTime = await getServerTime()
return <div className={'text-6xl'}>The server time is {serverTime}</div>
}1 Reply
Southern African anchovyOP
This is working fine when using the old pages router, the following works as expected:
const wait = async (ms: number) =>
new Promise((resolve) => {
setTimeout(resolve, ms)
})
const getServerTime = async () => {
await wait(2000)
return new Date().toLocaleTimeString()
}
export default function ISRTestPagesRouterPage({ serverTime }: { serverTime: string }) {
return <div className={'text-6xl'}>The server time is {serverTime}</div>
}
export const getStaticProps = async (context: any) => {
const serverTime = await getServerTime()
return { props: { serverTime }, revalidate: 10 }
}