1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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.
This commit is contained in:
Arunoda Susiripala 2017-03-12 09:21:49 +05:30 committed by GitHub
parent 0d01f5c8e8
commit 1ae3c2e637

View file

@ -3,6 +3,12 @@
import Router from '../lib/router'
import fetch from 'unfetch'
const originalRouteChangeComplete = Router.onRouteChangeComplete
Router.onRouteChangeComplete = (...args) => {
if (originalRouteChangeComplete) originalRouteChangeComplete(...args)
ping()
}
async function ping () {
try {
const url = `/_next/on-demand-entries-ping?page=${Router.pathname}`