3

I am using the $A.createComponents() method to dynamically insert different components into the body of my Lightning application. I am executing this function using a custom Lightning event where I am passing the $A.createComponent() method an attribute which is the name of the component that I want to render. On a button click event, the custom Lightning event fires, passing the component name to the $A.createComponents() method for dynamic rendering.

Periodically, I am getting the following error logged to my window once the component is dynamically rendered to the screen.

Invalid component tried calling function [getElement], markup://aura:html [132:c]

Even though this system error logs to the window, the component still renders. I'm not sure what is causing this error. It would help me troubleshoot it to have an idea of exactly what it means?

Could anyone provide some insight on this one?

Thanks!

1 Answer 1

4

Two possibilities here, you're trying to rerender an html element which is invalid. If this is the case, it's a framework bug since we should detect that.

The more likely scenario, you're calling .getElement() on a component, and that component has since been unrendered and destroyed.

Due to the asynchronous nature of the framework this just happens sometimes. You should gate the logic based on a isValid check.

if(cmp.isValid()) { 
 var element = cmp.getElement();
}
2
  • Kris, thanks for the info. Is there any way for me to tell which resource is causing the error? In just seeing the general error log on screen I'm not sure where to start looking. Aug 12, 2015 at 19:55
  • The 132:c at the end tells me it is probably in an action callback. Other than that, I'm unsure how to track it. To debug it, I would try to repro with the dev tools console open to break on exceptions.
    – Kris Gray
    Aug 13, 2015 at 16:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .