Is it possible to listen for when getInitialProps is called #10809
-
I use NProgress (a fake progress bar on top of the page) for user feedback while they wait for page transitions. I use it like this right now
Thing is I only need it when I go to a dynamic page since navigating to statically optimized pages is instant anyways. Is there a way I can listen to either the start/end of |
Beta Was this translation helpful? Give feedback.
Answered by
timneutkens
Mar 3, 2020
Replies: 1 comment
-
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()
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
csenio
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The better solution would be to add a delay to showing it and adding a debounce this is what we do for zeit.co: