Open gsabran opened 8 years ago
I too ran into this issue. Which happens to be the same issue as https://github.com/kadirahq/flow-router/issues/585. I couldn't figure out exactly what is supposed to happen but I think I tracked it down to this section of router.js:
// Implementing idempotent routing
// by overriding page.js`s "show" method.
// Why?
// It is impossible to bypass exit triggers,
// because they execute before the handler and
// can not know what the next path is, inside exit trigger.
//
// we need override both show, replace to make this work
// since we use redirect when we are talking about withReplaceState
_.each(['show', 'replace'], function(fnName) {
var original = self._page[fnName];
self._page[fnName] = function(path, state, dispatch, push) {
var reload = self.env.reload.get();
if (!reload && self._current.path === path) {
return;
}
original.call(this, path, state, dispatch, push);
};
});
self._current.path === path
is not true when the problem arises. self._current.path
is the correct withReplaceState URL but path
is the previous URL
but path is always passed to original.call
@arunoda, I'd be happy to try and submit a pull request for this if you find a moment to weigh in on whether I might be on the right path
It seems that
withReplaceState
doesn't replace state, but instead doesn't write new state to the history.Will go to
silentRoute
and the history will be [route
];Would it be possible to get the opposite, ie:
Where the history will be [
route
]Use case is when
silentRoute
is a tracking route that I don't want to keep in the history. Sorry I could not understand the code well enough to do a PR