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

Update routing samples (#4864)

Updated router samples to use the EventEmitter
This commit is contained in:
Jacob Page 2018-08-13 14:17:39 -07:00 committed by Tim Neutkens
parent b9081a5115
commit 1889c80472
2 changed files with 5 additions and 7 deletions

View file

@ -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 }) => (
<div>

View file

@ -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 }) {