Exam CRT-450 Topic 1 Question 47 Discussion
Actual exam question for Salesforce's CRT-450 exam
Question #: 47
Topic #: 1
Question #: 47
Topic #: 1
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 clicks a button called Next in the child component, the parent component must be alerted so it can navigate to the next page.
How should this be accomplished?
One of the child components is used for navigation purposes. When a user clicks a button called Next in the child component, the parent component must be alerted so it can navigate to the next page.
How should this be accomplished?
Suggested Answer: C Vote an answer
To notify the parent component from a child component when a button is clicked:
Option C: Create a custom event
Child Component:
// ChildComponent.js
handleClick() {
const nextEvent = new CustomEvent('next');
this.dispatchEvent(nextEvent);
}
Parent Component:
<!-- ParentComponent.html -->
<c-child-component onnext={handleNext}></c-child-component>
javascript
Copy code
// ParentComponent.js
handleNext() {
// Navigate to the next page
}
Reference:
"To communicate up the component containment hierarchy, fire a custom event in the child component."
- Lightning Web Components Developer Guide: Communicate with Events
Why Other Options Are Incorrect:
Option A: Updating a property on the parent directly is not possible from the child.
Option B: "Fire a notification" is vague and not a standard mechanism.
Option D: Calling a method in the Apex controller does not facilitate child-to-parent communication within components.
Option C: Create a custom event
Child Component:
// ChildComponent.js
handleClick() {
const nextEvent = new CustomEvent('next');
this.dispatchEvent(nextEvent);
}
Parent Component:
<!-- ParentComponent.html -->
<c-child-component onnext={handleNext}></c-child-component>
javascript
Copy code
// ParentComponent.js
handleNext() {
// Navigate to the next page
}
Reference:
"To communicate up the component containment hierarchy, fire a custom event in the child component."
- Lightning Web Components Developer Guide: Communicate with Events
Why Other Options Are Incorrect:
Option A: Updating a property on the parent directly is not possible from the child.
Option B: "Fire a notification" is vague and not a standard mechanism.
Option D: Calling a method in the Apex controller does not facilitate child-to-parent communication within components.
by Norton at Jun 26, 2026, 12:39 AM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).