Skip to content

Commit 1ae3c2e

Browse files
authored
Ping to on-demand-entries on every page change. (#1384)
This will prevent disposing the page after viewing it. Otherwise, it'll possible to dispose the page even we load the page on the client.
1 parent 0d01f5c commit 1ae3c2e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

client/on-demand-entries-client.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
import Router from '../lib/router'
44
import fetch from 'unfetch'
55

6+
const originalRouteChangeComplete = Router.onRouteChangeComplete
7+
Router.onRouteChangeComplete = (...args) => {
8+
if (originalRouteChangeComplete) originalRouteChangeComplete(...args)
9+
ping()
10+
}
11+
612
async function ping () {
713
try {
814
const url = `/_next/on-demand-entries-ping?page=${Router.pathname}`

0 commit comments

Comments
 (0)