Route Events handlers are not being called
See original GitHub issueFollowing the instructions in README to listen to route events doesn’t work
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
It should be called and I should see the console logs
Current Behavior
Nothing
Steps to Reproduce (for bugs)
- Add the code (either in pages/*.js or pages/_document.js)
// onRouteChangeStart(url) - Fires when a route starts to change
Router.onRouteChangeStart = (url) => {
console.log('App is changing to: ', url)
}
// onRouteChangeComplete(url) - Fires when a route changed completely
Router.onRouteChangeComplete = (url) => {
console.log('App has changed to: ', url)
}
// onRouteChangeError(err, url) - Fires when there's an error when changing routes
Router.onRouteChangeError = (err, url) => {
console.log('App has error when changing: ', err, url)
}
// onBeforeHistoryChange(url) - Fires just before changing the browser's history
Router.onBeforeHistoryChange = (url) => {
console.log('App is changing to before history change: ', err, url)
}
// onAppUpdated(nextRoute) - Fires when switching pages and there's a new version of the app
Router.onAppUpdated = (nextRoute) => {
console.log('App is updating to: ', nextRoute)
}
- Refresh the page, and click around and add some Router.push events
- Nothing in inspector
- ??
Context
I can’t use this to track pageviews for my in-house analytics system.
Your Environment
Tech | Version |
---|---|
next | 2.4.6 |
node | 8.1.3 |
OS | 10.12.5 |
browser | chrome 60.0.3112.72 (Official Build) beta (64-bit) |
etc |
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Route Events handlers are not being called #2644 - GitHub
I currently have the problem that onRouteChangeStart is called, but onRouteChangeComplete is not despite the fact that I visually see the ...
Read more >Event handlers not being called with React and Electron
I'm trying out Electron and I've set up an app with typescript and react. My react components in the renderer aren't responding to...
Read more >Event listeners not working? 3 key areas to troubleshoot
Are your event listeners not working as you'd expect? Here are 3 key areas to troubleshoot to help you get everything triggering as...
Read more >How-To: Route messages to different event handlers
Learn how to route messages from a topic to different event handlers based on CloudEvent fields.
Read more >Events and routed events overview - UWP - Microsoft Learn
Registering handlers for already-handled routed events Earlier we said that setting Handled to true prevents most handlers from being called.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I currently have the problem that
onRouteChangeStart
is called, butonRouteChangeComplete
is not despite the fact that I visually see the changes e.g. it successfully changed the route…What can I do?
Thanks, will test again later.