Lightning Web Components Flashcards
What happens if you try to directly modify an object passed from a parent to a child?
An invalid mutation error is thrown.
True or false: bound properties in {} can contain spaces.
False.
What is the easiest way to work with Salesforce data in an LWC?
Use base Lightning components built on the Lightning Data Service (LDS).
Which property of an event includes any sent data?
detail
What is the syntax for loading the account object into a variable named ACCOUNT_OBJECT?
import ACCOUNT_OBJECT from “@salesforce/schema/Account”;
Which two properties does a record page provide?
recordId and objectApiName
How do you conditionally display content in an LWC?
Nest a template tag(s) with the lwcI:if={someProperty}. The lwc:elseif and lwc:else properties can also be used.
How would you reference a component named viewSource in markup?
<c-view-source>
How do you conditionally render markup in LWCs?
Use the lwc:if, lwc:elseif, and lwc:else attributes.
What is the preferred, and easiest way to work with data in an LWC?
Lightning Data Service.
In which directory are message channels stored?
force-app/main/default/messageChannels
What is the proper syntax to import a method named myMethod from MyClass as MY_METHOD?
import MY_METHOD from ‘@salesforce/apex/MyClass.myMethod;
What is a slot?
A placeholder for markup that a parent component passes into a component’s body.
What is the file name format for a message channel?
messageChannelName.messageChannel-meta.xml
Which method is used for dispatching events?
dispatchEvent()
Which decorator exposes a field as a public property?
@api
Which attribute is set to listen for an event on an input element?
onchange
True or false: if you write a setter for a public property, you must also write a getter.
True.
What would be the property syntax to import the method named queryAccounts that is marked @AuraEnabled and part of the class AccountListController into an LWC?
import queryAccounts from ‘@salesforce/apex/AccountListController.queryAccounts’;
Which decorator marks a field as public?
@api
True or false: an LWC folder and its file must have the same name, including capitalization and underscores.
True.
True or false: all fields are reactive.
True.
True or false: an LWC file/folder must begin with a lowercase letter.
True.
How do you control when Apex method invocation occurs in an LWC?
Call the method imperatively.