Sunday, September 26, 2021

Lightning Web Components Interview Questions-Part 3

 

21. How to we can use Lightning Web Components outside Salesforce

You can check details here: Use Lightning Web Components in External WebSite Lightning out

22. Is it possible to iterate map in Lightning Web Components

We don’t have native OOTB support here, but we can iterate map in Lightning web components. You can check details here: Iterate Map in Lightning web components LWC

23. How to iterate sObject list in Lightning Web Components

We don’t have native OOTB support here, but we can iterate sObject list in Lightning web components. You can check details here: Display generic sObject in Lightning Web Components

24. How to access labels in Lightning web components

import labelName from '@salesforce/label/labelReference';

25. What is the Lightning Message Service

You can check details here: Lightning Message Service (LMS)

26. How to access events in Lightning Web Components

You can check details here: pas data between components using Events in Lightning Web Components

27. Where you can use/access Lightning Web components in Salesforce

We can use LWC in Flow, Lightning App Builder, Lightning Community, Utility Bar, Stand Alone Aura App, Custom tab and Visualforce, Salesforce Flow.

28. Explain Flow of lightning Web Components (LWC)

Flow of Lightning web components, Interview questions of LWC

28. Explain Styling Hooks for Lightning Web Components

Styling hooks provide a way for us to customize the default appearance of our LWC-based Base Components in a supported, maintainable, and intuitive way. You can check step by step guide here.

29. What is Aura Tokens?

Design Tokens are named entities that store visual design attributes. We use them in place of hard-coded values (such as hex values for color or pixel values for spacing) in order to maintain a scalable and consistent system for UI development.

To create a tokens bundle:

  1. In the Developer Console, select File | New | Lightning Tokens.
  2. Enter a name for the tokens bundle. The first tokens bundle should be named defaultTokens. The tokens defined within defaultTokens are automatically accessible in your Lightning components. Tokens defined in any other bundle won’t be accessible in your components unless you import them into the defaultTokens bundle.
<aura:tokens> 
    <aura:token name="myBodyTextFontFace" 
               value="'Salesforce Sans', Helvetica, Arial, sans-serif"/>
    <aura:token name="myBodyTextFontWeight" value="normal"/>
    <aura:token name="myBackgroundColor" value="#f4f6f9"/>
    <aura:token name="myDefaultMargin" value="6px"/>
</aura:tokens>

30. How you can use Aura Tokens and SLDS Design Token in LWC

To use custom Aura Tokens in LWC we need to follow below format:

// myLightningWebComponent.css
color: var(--c-myBackgroundColor);

LWC can use any Lightning Design System design token marked with Global Access. You can check the list here:

/* myLightningWebComponent.css */
div {
    margin-right: var(--lwc-spacingSmall);
}