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:
parent
b9081a5115
commit
1889c80472
|
@ -4,9 +4,7 @@ import Header from './Header'
|
||||||
|
|
||||||
import * as gtag from '../lib/gtag'
|
import * as gtag from '../lib/gtag'
|
||||||
|
|
||||||
Router.onRouteChangeComplete = url => {
|
Router.events.on('routeChangeComplete', url => gtag.pageview(url))
|
||||||
gtag.pageview(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ({ children }) => (
|
export default ({ children }) => (
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -8,12 +8,12 @@ const linkStyle = {
|
||||||
margin: '0 10px 0 0'
|
margin: '0 10px 0 0'
|
||||||
}
|
}
|
||||||
|
|
||||||
Router.onRouteChangeStart = (url) => {
|
Router.events.on('routeChangeStart', (url) => {
|
||||||
console.log(`Loading: ${url}`)
|
console.log(`Loading: ${url}`)
|
||||||
NProgress.start()
|
NProgress.start()
|
||||||
}
|
})
|
||||||
Router.onRouteChangeComplete = () => NProgress.done()
|
Router.events.on('routeChangeComplete', () => NProgress.done())
|
||||||
Router.onRouteChangeError = () => NProgress.done()
|
Router.events.on('routeChangeError', () => NProgress.done())
|
||||||
|
|
||||||
export default class MyApp extends App {
|
export default class MyApp extends App {
|
||||||
static async getInitialProps ({ Component, router, ctx }) {
|
static async getInitialProps ({ Component, router, ctx }) {
|
||||||
|
|
Loading…
Reference in a new issue