Code By Code – Lightning Framework – Chapter 12 – Inheritance In Lightning

Code By Code – Lightning Framework – Chapter 12 – Inheritance In Lightning

Chapter 12

Topics for this chapter:

  • Inheritance In Aura Component

Inheritance In Aura Component

Similar to all other modern framework and programming languages, the Lightning framework also supports Inheritance. Using inheritance is one way to share the common code between multiple components.

Inheritance in Lightning allows you to inherit parent component’s attributes, body attributes, events, helper and client-side controller.

Creating A Base Component To Be Inherited

Base.cmp
BaseHelper.js File:

Final Code Of CarSearchForm Component

CarSearchForm.cmp

CarSearchFormController.js

CarSearchFormHelper.js

What does this code speak?

In the above code, the Base component is an aura component which needs to be inherited by CarSearchForm component.
1. To make a component available for inheritance, you need to declare the abstract property to true.
2. In helper file, I have defined a few methods which will be called from CarSearchForm helper file.
3. To extend the Base component in CarSearchForm component, you need to extend it in the component.
4. In helper file, you can call Base component’s helper method simply referring them as helper.methodName().

Lightning Component Development Day5 - Server Side Controller, Apex, Inheritance In Lightning

Test your knowledge

Inheritance In Aura Component

Next In This Guide

Manish Choudhari

I am a certified Salesforce Application & System Architect and Developer working on Salesforce Technology since 2014. Currently, I have 14 Salesforce certifications along with OCPJP (Oracle Certified Profession JavaSE6 Programmer) working in Salesforce.com Hyderabad as a Technical Engineer. Writing technical blogs, learning new technologies and frameworks and sharing knowledge is my hobby.

This Post Has One Comment

Leave a Reply

Close Menu