A developer is building a Lightning Web Component that needs to navigate to a specific record page when a user clicks a button. The developer wants to use the NavigationMixin from lightning/navigation. The component is a child component nested inside another component, and the developer needs to ensure that the navigation works correctly. Which code snippet correctly uses NavigationMixin to navigate to an Account record page?
This snippet correctly uses the NavigationMixin.Navigate method with a page reference object. The type 'standard__recordPage' is used to navigate to a record page, and the attributes specify the recordId, objectApiName, and actionName. This is the standard way to navigate to a record page in LWC using NavigationMixin.
Why this answer
The correct code uses this[NavigationMixin.Navigate] with a page reference object of type 'standard__recordPage'. This is the standard pattern for navigation in LWC. The mixin is applied to the class, and the Navigate method is accessed via bracket notation on the instance.
The other options either use incorrect syntax or pass invalid arguments.
Exam trap
The trap here is using dot notation instead of bracket notation for the mixed-in Navigate method, or assuming Navigate can be called statically.