iron-meteor/iron-layout

"You called beginRendering again before calling endRendering"

Closed this issue · 8 comments

I see this a lot now after upgrading to devel iron-router:

Layout.prototype.beginRendering = function () {
  if (this._renderedRegions)
    throw new Error("You called beginRendering again before calling endRendering");
  this._renderedRegions = {};
};

I error there, on the error thrown.

My observations of the state of the app when this error is thrown:

  • I will hit the error, and one of the regions in the layout will be rendered, but a different one will not. For example, I'll have this layout:

    <template name="layout">
    {{> yield region='navbar'}}
    
    <div id="container-main" class="container layout-1up">
        {{> yield region='sidebar'}}
    
        <div id="inner-main">
            {{> yield}}
        </div>
    </div>
    </template>
    

    and the main yield will have rendered, the navbar will have not rendered, and I throw the error.

  • I'm in a route with a reactive action. This may be a red herring.

    ...
          action: function () {
              // Something reactive:
              if (Meteor.user()) {
                  // Dies here:
                  this.redirect('some path');
              } else {
                  this.render();
              }
          }
    ...
    });
    

Hey @doctorpangloss, I'm not seeing this error. Do you have a small reproduction I can look at? You probably discovered an edge case I haven't seen yet.

I'm building it out now, I'll follow up here

thks

K repro'd really minimally.

https://github.com/doctorpangloss/iron-layout-4-repro

This occurs when a redirect takes you back to where you came from.

I think I can help you out with your package, and we may have some more things to chat about. I will message you privately!

oh blasted i see. need to endRendering without causing a flush when the controller stops. will fix that in a second.

thanks for spotting this @doctorpangloss and for the repro! It should be fixed now. Let me know!

solved in 0.1.2, perfect

sweet!