danielr18 / connected-next-router

A Redux binding for Next.js Router compatible with Next.js.
MIT License
109 stars 30 forks source link

Is time travel enabled fix #56

Closed DZakh closed 3 years ago

DZakh commented 3 years ago

When I initially open a static page (haven't tested it with SSR), the trackRouteStart isn't called but the trackRouteComplete is. Because of this ongoingRouteChanges.current becomes -1 and the lib thinks that the isTimeTravelEnabled.current is always true.
This leads to a bug when you change a page, store changes, triggers listenStoreChanges and the locationMismatch sends you to the previous page.

Well, I've fixed only the couse not a reason, but it's always better to have this kind of check, because if the counter becomes negative, then there's definitely something wrong.
But I'd still recommend you to figure out why trackRouteStart doesn't work on the first load.

danielr18 commented 3 years ago

This should be fixed with V4, but if it's reported again, it can be re-opened.