Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

First render - unneccasary history.pushState #51

Closed
tomatau opened this issue Nov 27, 2015 · 1 comment
Closed

First render - unneccasary history.pushState #51

tomatau opened this issue Nov 27, 2015 · 1 comment

Comments

@tomatau
Copy link
Contributor

tomatau commented Nov 27, 2015

On first page render, if redux DebugPanel is displayed, the simple router calls history.pushState with the existing route. This means that Router.createElement is invoked twice on ReactRouter - which isn't necessary.

The redux DevTools or perhaps LogMonitor seems to trigger the store.subrscribe callback on an interval. Here, RSR is finding that lastChangeId !== routing.changeId; and so calling the new pushState.

It could be worth caching the routePath and checking for a difference with the current getState().routing.path before invoking updatePath, but of course, that wouldn't take into account any route state changes.

It may be more simple to initialise the lastChangeId to the same value as initialState.changeId - again, there's probably a use case in here somewhere that route.state updates on initial render wouldn't be taken into account...

Perhaps #50 could prevent the unnecessary pushState call on initial render.

@jlongster
Copy link
Member

We cannot diff paths, that's what we used to do and it is not reliable at all. In fact we want to call into the router for every single URL change -- even if it's the same URL!

But I think you might be right about initializing the lastChangeId. Let's merge this with #50.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants