kadirahq / flow-router

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

FlowRouter.current() in triggersEnter now previous route in SSR 3.8.0 #497

Closed TedAvery closed 8 years ago

TedAvery commented 8 years ago

Prior to 3.8.0 I was doing this to set my page titles, and it worked fine:

FlowRouter.triggers.enter([function() {
  DocHead.setTitle(FlowRouter.current().route.name);
}]);

But now when triggersEnter is fired, FlowRouter.current() on first load is an object with undefined queryParams and params attributes, and when fired again later, it is always set to the info of the route we just left.

tomwasd commented 8 years ago

Hi @TedAvery,

I was doing the same as you but try passing in the context param instead:

FlowRouter.triggers.enter([function(context) {
  DocHead.setTitle(context.route.name);
}]);

I believe that should work.

arunoda commented 8 years ago

@tomwasd @TedAvery That's the correct way. You are inside a trigger and it's not the current route yet.

arunoda commented 8 years ago

Reopen if this doesn't solves.