veliovgroup / flow-router

🚦 Carefully extended flow-router for Meteor
https://packosphere.com/ostrio/flow-router-extra
BSD 3-Clause "New" or "Revised" License
201 stars 30 forks source link

this.render regions reloading whole page #85

Closed CyberCyclone closed 3 years ago

CyberCyclone commented 3 years ago

I'm having an issue:

I'm having an issue where all regions are reloading even though the parent region shouldn't change. Using the below code renders the Layout_body and region 'Page_home' correctly.

FlowRouter.route('/', {
    name: 'index',
    action() {
        // Render a template using Blaze
        this.render('Layout_body', {main: 'Page_home'});
    }
});

I then have this code and if I change routes (<a href="/faq">FAQ</a>), both the Layout_body and Page_faq load. As in, the Layout_body gets reloaded as well. I've added a console.log to the onCreated and onRendered for Layout_body and it's printing out on every layout change, when it should only be running once on the initial load.

FlowRouter.route('/faq', {
    name: 'frequently asked questions',
    action() {
        // Render a template using Blaze
        this.render('Layout_body', {main: 'Page_faq'});
    }
});

As far as I know this isn't meant to be by design and Layout_body should have only run once.

Thanks!

dr-dimitru commented 3 years ago

Hello @CyberCyclone,

Please read .render() method documentation. When passing only single template name it is treated as a Template not a Layout.

Feel free to close it in case if the issue is solved on your end.

CyberCyclone commented 3 years ago

From the documentation I interpreted this.render('Layout_body'); to be a template and this.render('Layout_body', {main: 'Page_home'}); to be a layout with template regions.

Using this.render('Layout_body', 'Page_home'); works as you said.

dr-dimitru commented 3 years ago

@CyberCyclone great! I'm glad this was quickly solved :)


Please support this project with: