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.
An array of Contact fields has been declared named FIELDS. What is the proper syntax to use these fields when wiring in to a property?
@wire(getRecord, {recordId: ‘$recordId’, fields: FIELDS})
What is the syntax to create a child component named myComponent and set a public property named myProperty to the value of a primitive named test?
<c-my-component my-property="test"><c-my-component>
What decorator must be used to call an Apex method from an LWC?
@AuraEnabled
What would the syntax be to define an iterator named it that iterates over an array named accounts?
<template iterator:it={accounts}>
What is required to expose an Apex method to an LWC?
The method must be static, either global or public, and annotated with the method @AuraEnabled.
What is the filename for a component configuration file for an LWC named myComponent?
myComponent.js-meta.xml
True or false: an Apex method that isn’t annotated with cacheable=true must be called imperatively.
True.
How do you make an LWC visible in an org?
In the metadata component file, set the <isExposed> attribute to true and create <target> attribute(s) nested inside a <targets> attribute to specify which types of pages the component be added to.</targets></target></isExposed>
Which properties does a wired property have by default?
data and error