Navigate to a URL-Addressable Component (Summer '24)
Bhanu Prakash Medikurthi
8x Certified Sr. Salesforce Developer || All Star Trailhead Ranger || Trailhead Quest Winner
1.Add lightning__UrlAddressable to the meta xml file.
<LightningComponentBundle xmlns="https://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__UrlAddressable</target>
</targets>
</LightningComponentBundle>
2.using the NavigationMixin, navigate the user to target component.
this[NavigationMixin.Navigate]({
type: "standard__component",
attributes: {
componentName: "c__MyComponent",
},
state: {
c__optionalState: "stateValue",
},
});
To navigate to the component, use the standard__component page reference type.
Include the required attributes and optional state objects.
3.use a getter to return the property value from the state object in target component
@wire(CurrentPageReference)
currentPageRef;
@api propertyValue;
get propertyValue() {
return this.currentPageRef.state.c__propertyValue;
}
Currently Upskilling in Agentforce. Looking for interested people to join me as a team for Agentforce Hackathon Bengaluru.
7 个月Very informative. Please include images and stylings and use more hashtags to reach the community.