Salesforce-Platform-Developer Practice Test

Salesforce Spring 25 Release
237 Questions

Which two characteristics are true for Lightning Web Component custom events? Choose 2 answers

A. Data may be passed In the payload of a custom event using a wire decorated properties.

B. By default a custom event only propagates to its immediate container and to its immediate child component.

C. By default a custom event only propagates to it's immediate container.

D. Data may be passed in the payload of a custom event using a property called detail.

C.   By default a custom event only propagates to it's immediate container.
D.   Data may be passed in the payload of a custom event using a property called detail.

Explanation:

Lightning Web Components (LWC) use custom events for communication between components, especially from child to parent. Here’s what’s true:

C. By default a custom event only propagates to its immediate container.
Custom events in LWC do not bubble beyond the immediate parent unless the event is explicitly configured with bubbles: true.

D. Data may be passed in the payload of a custom event using a property called detail. To pass data in a custom event, you use the detail property:

this.dispatchEvent(new CustomEvent('myevent', { detail: { value: 'something' } }));

Why the other options are incorrect:

A. Data may be passed in the payload using wire-decorated properties
@wire is for data retrieval, not for event communication. Custom events don't use @wire for passing data.

B. Custom event propagates to both immediate container and child
Custom events propagate upward (to containers), not downward to child components.

Salesforce-Platform-Developer Practice-Test - Home Previous
Page 8 out of 237 Pages