Checkout earlier posts in interview question series to read previous questions.
91. What are the lifecycle events?
There are 4 events that get fired as per component rendering lifecycle:
- Init event – Updates a component or fires an event after component construction but before rendering.
- render() – Renders the component body.
- afterRender() – Enables you to interact with framework after the component bodies are inserted.
- render event – handled by the framework is preferred over creating a custom render() and overriding afterRender().
92. How can you handle the init event?
Use aura handler to handle init event. In below example, define a doInit method in controller file to execute some functionality on component initialization.
<aura:handler name=“init” value=”{!this}” action=“{!c.doInit}”/>
93. How can you handle render event?
Use aura handler to handle render event. In below example, define a doRender method in controller file to execute some functionality after component rendering is done.
<aura:handler name=“render” value=”{!this}” action=“{!c.doRender}”/>
94. Which interface allows you to put your component inside Lightning Builder pages?
There are two interfaces which can make your component available for app builder pages.
- flexipage:availableForRecordHome – This interface make your component available to be used inside a Lightning App builder record page.
- flexipage:availableForAllPageTypes – This interface make your component available to be used inside all Lightning Pages, like record page, app page, and home page.
95. What is the difference between force:lightningQuickAction and force:lightningQuickActionWithoutHeader?
Both of these interfaces make your component available to be deployed as a quick action.
– force:lightningQuickAction interface display in a panel with standard action controls, such as a Cancel button. These components can display and implement their own controls in the body of the panel, but can’t affect the standard controls.
– force:lightningQuickActionWithoutHeader display in a panel without additional controls and are expected to provide a complete user interface for the action.
You cannot use both of these interfaces together. That is, components can implement either the force:lightningQuickActioninterface or the force:lightningQuickActionWithoutHeader interface, but not both.
96. How can you get current recordId and sObject name in lightning component deployed on record page?
– To get record id, implement force:hasRecordId interface, which will put the record id in an attribute named “recordId”.
– To get sObject name, implement force:hasSObjectName interface, which will put the sObject name in an attribute named “sObjectName”.
Also Read: Generic Record Handler Lightning Component
97. How can you create a lightning tab with the lightning component?
To create a lightning tab, you need to implement “force:appHostable” interface in your component.
98. Why we use lightning:actionOverride interface?
To override standard buttons with an aura component, lightning:actionOverride interface needs to be implemented.
99. How can we use an aura component in the community?
forceCommunity:availableForAllPageTypes interface makes an aura component available to be used in lightning communities.
100. How can you use aura component in lightning flows?
There are 2 interfaces which allow us to use aura component within flows.
- lightning:availableForFlowActions – Add the lightning:availableForFlowActions interface to a Lightning component to make it available as a flow action. When a component is executed as a flow action, the flow calls the invoke method in the client-side controller. Flows that include Lightning components are supported only in Lightning runtime.
- lightning:availableForFlowScreens – Add the lightning:availableForFlowScreens interface to a Lightning component to make it available for flow screens. This interface is supported only in Lightning runtime.