Saving route params in template state is redundant and unnecessary, right?

Hi,

I am using FlowRouter with Blaze.
The route definition has a param named page which is store on a reactive-dict
then the value from the state is used like:
Template.instance().state.get('page')

That is redundant and unnecessary, right?
You can simply get the param like:
FlowRouter.getParam('page')

Please share your thoughts.

You are absolutely right. Additionally if you have a reactive context that relies on one to set the other, then you’ll get double runs of the reactive computation.

2 Likes

Depends on how strictly you are separating your components into smart and dumb. ie:
http://blazejs.org/guide/smart-components.html


Also known as Presentational and Container components:

You might want to load the page using flow router and then pass it to the presentational component that displays it in some way. This is done in Blaze by passing data context to a child template, in which case you should just pass the page as data and not in a state.

Of course, this level of separation is overkill for a lot of projects and you will instead use hybrid components that load their own data. In which case just use FlowRouter.getParam directly without state

2 Likes

Yes, actually it was running twice.

Thanks I will read the articles.