5

I'm working on a very styled Lightning Community (we're using Napili, but with a custom Theme, custom Layouts, custom CSS) and one thing which looks odd is the rendering order when you load a page.

  1. First thing to appear is the header and footer, with nothing in-between them
  2. Then the content components in-between appear, but without any data
  3. Then the AJAX responses come back, populating the content components.

Now, we can deal with the wait between 2 and 3 by using Stencils (https://www.lightningdesignsystem.com/guidelines/loading/). But, there doesn't seem to be anything we can do about the wait between 1 and 2. There's just an ugly snap between a page which is just header + footer, to something with components in-between.

I've tried hiding the footer component until it receives an aura:doneRendering event. As I expected (since the docs say this isn't a good idea), I found that event was fired a whole load of times and - crucially - the the first firing was before the content components started to render so it didn't help at all.

Any ideas?

-1

You can use renderer.js file in your component. what you can do is write your logic in this method. you can call helper method from here also. This method will be called only once.

afterRender: function (component, helper) {
        this.superAfterRender();

    }
3
  • 2
    I'm not sure you've grasped the question... 1. Custom renderers are no longer the recommended way to know that a component is rendered. As of v40, you should handle the render event instead. 2. Where would you even do that? If I take action after the Theme component is rendered, that doesn't mean the actual content has been rendered so it's too early. I tried catching the render event from the content in Theme component, but without success. – Aidan Jul 13 '17 at 10:56
  • @Aiden .. i didnot know about render Event so we were using custom renderers. +1 for letting me know. – Manjot Singh Jul 13 '17 at 11:11
  • I have used afterrender to find out width and height of a component. – Manjot Singh Jul 13 '17 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.