kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 193 forks source link

withReplaceState unexpected behaviour #585

Open Cliffzz opened 8 years ago

Cliffzz commented 8 years ago

Reproduce repo: https://github.com/Cliffzz/flow-router-replace-state

When using FlowRouter.withReplaceState in onRendered the url's won't replace properly and the history is messed up:

Example:

Template.one.onRendered(function () {
    FlowRouter.withReplaceState(function() {
        FlowRouter.go('/2');
    });
});

When I set a Meteor.setTimeout it works as expected:

Template.oneWithTimeout.onRendered(function () {
    Meteor.setTimeout(function () {
        FlowRouter.withReplaceState(function () {
            FlowRouter.go('/2');
        })
    }, 100);
});