diff --git a/examples/with-google-analytics/components/Page.js b/examples/with-google-analytics/components/Page.js index 421c5f2b..3677fa4e 100644 --- a/examples/with-google-analytics/components/Page.js +++ b/examples/with-google-analytics/components/Page.js @@ -4,9 +4,7 @@ import Header from './Header' import * as gtag from '../lib/gtag' -Router.onRouteChangeComplete = url => { - gtag.pageview(url) -} +Router.events.on('routeChangeComplete', url => gtag.pageview(url)) export default ({ children }) => (
diff --git a/examples/with-loading/pages/_app.js b/examples/with-loading/pages/_app.js index f6739c1b..0071bbb3 100644 --- a/examples/with-loading/pages/_app.js +++ b/examples/with-loading/pages/_app.js @@ -8,12 +8,12 @@ const linkStyle = { margin: '0 10px 0 0' } -Router.onRouteChangeStart = (url) => { +Router.events.on('routeChangeStart', (url) => { console.log(`Loading: ${url}`) NProgress.start() -} -Router.onRouteChangeComplete = () => NProgress.done() -Router.onRouteChangeError = () => NProgress.done() +}) +Router.events.on('routeChangeComplete', () => NProgress.done()) +Router.events.on('routeChangeError', () => NProgress.done()) export default class MyApp extends App { static async getInitialProps ({ Component, router, ctx }) {