10

If I have a component in my markup that may at some point be deleted (like a modal), it seems I have 2 solutions:

-Set the facet attribute to []

myParentComponent.set("v.myFacet", []);

-Call the destroy() method of this component

myComponentToDestroy.destroy();

Is there any difference between the 2 solutions, either in terms of speed or memory management ?

1

As per the document, Component.destroy() is used to avoid the memory leaks for the components which we do not add them as a facet or to the body.

For the components which are added as a facet or to the body, framework takes care of destroying them if they are no longer available in the mark up.

  • If you are using facet you may set it to '[]' and the framework will destroy the component for you. – Vijay Apr 9 '17 at 23:55

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.