exam questions

Exam CRT-450 All Questions

View all questions & answers for the CRT-450 exam

Exam CRT-450 topic 1 question 312 discussion

Actual exam question from Salesforce's CRT-450
Question #: 312
Topic #: 1
[All CRT-450 Questions]

What are two best practices when it comes to Lightning Web Component events? (Choose two.)

  • A. Use event.detail to communicate data to elements in the same shadow tree.
  • B. Use CustomEvent to pass data from a child to a parent component.
  • C. Use event.target to communicate data to elements that aren't in the same shadow tree.
  • D. Use events configured with bubbles: false and composed: false.
Show Suggested Answer Hide Answer
Suggested Answer: BD 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
govosen887
1 year, 2 months ago
Selected Answer: BD
https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.events_best_practices
upvoted 3 times
...
DonAldos
1 year, 2 months ago
Selected Answer: AB
A and B are two best practices when it comes to Lightning Web Component events. A. Use event.detail to communicate data to elements in the same shadow tree. This is a good practice because the detail property is a JavaScript object that can be used to communicate complex data between components. B. Use CustomEvent to pass data from a child to a parent component. CustomEvent is a good practice because it allows a child component to communicate with its parent component. By using CustomEvent, the child component can send a message to the parent component with any data it needs to share.
upvoted 1 times
briccoli11
11 months, 2 weeks ago
I don't think A is correct - based on this source: https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.events_best_practices it says: "To communicate data to elements that aren’t in the same shadow tree, use event.detail. " It also says "Use events configured with bubbles: false and composed: false because they're the least disruptive." Meaning D is correct. I think the correct answer is BD
upvoted 1 times
...
...
AppleDash
1 year, 5 months ago
Sorry B D
upvoted 4 times
...
AppleDash
1 year, 5 months ago
B C https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.events_best_practices https://developer.salesforce.com/docs/component-library/documentation/en/lwc/events_create_dispatch
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

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.

SaveCancel
Loading ...