Skip to content

Is it possible to listen for when getInitialProps is called #10809

Answered by timneutkens
csenio asked this question in Help
Discussion options

You must be logged in to vote

The better solution would be to add a delay to showing it and adding a debounce this is what we do for zeit.co:

import debounce from 'lodash.debounce'
const start = debounce(NProgress.start, 500)
Router.events.on('routeChangeStart', start)
Router.events.on('routeChangeComplete', url => {
  start.cancel()
  NProgress.done()
  metrics.pageview(url)
  trackRenderPerformance()
})
Router.events.on('routeChangeError', () => {
  start.cancel()
  NProgress.done()
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by csenio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants