PDI · Question #23
PDI Question #23: Real Exam Question with Answer & Explanation
The correct answer is D: Create a custom event.. Child Lightning Web Components communicate with parent components by dispatching custom events, which the parent then listens for and handles.
Question
A developer is creating an app that contains multiple Lightning web components. One of the child components is used for navigation purposes. When a user click a button called.. component, the parent component must be alerted so it can navigate to the next page. How should this be accomplished?
Options
- AFire a notification.
- BUpdate a property on the parent.
- CCall a method in the Apex controller.
- DCreate a custom event.
Explanation
Child Lightning Web Components communicate with parent components by dispatching custom events, which the parent then listens for and handles.
Common mistakes.
- A. Firing a notification typically refers to showing a toast message to the user, not a direct programmatic communication channel between two components for internal application logic.
- B. Child components cannot directly update properties on a parent component; properties flow unidirectionally from parent to child in Lightning Web Components.
- C. Calling a method in the Apex controller handles server-side operations and database interactions, but it does not facilitate direct communication between client-side Lightning web components.
Concept tested. LWC Child-to-Parent Communication
Topics
Community Discussion
No community discussion yet for this question.