cyclejs-community / cyclic-router

Router Driver built for Cycle.js
MIT License
109 stars 25 forks source link

Router renders components twice with hash history #148

Open wmaurer opened 7 years ago

wmaurer commented 7 years ago

With HTML5 History API, the user agent fires a popstate event when the user navigates through their history, whether backwards or forwards, provided it isn’t taking the user away from the current page: http://html5doctor.com/history-api/#historical-events

As far as I understand it, this means that when using hash history - createHashHistory(), both a PUSH and a POP emitted.

@cycle/history also emits both of these events. You can see this by adding a debug to history$ in RouterSource, e.g. on line 39 of RouterSource.ts (when using the hash history).

However I believe it should be up to cyclic-router to filter out the POPs. The unfortunate consequence of getting both events is that components are rendered twice on every route change (when using hash history).

What do you think @TylorS?