0

Using LWC NavigationMixin to redirect user to an Aura component, is there a way for Aura cmp to receive values from the LWC? I am trying pass the values of propertyValue and c__id to the Aura cmp

    import { LightningElement, api } from 'lwc';
    import { NavigationMixin } from 'lightning/navigation';

    export default class MobileNavigation extends NavigationMixin(LightningElement) {  
    handleNavigate() {
        var compDefinition = {
            type: 'standard__component',
            componentDef: "c:TestAuraComponent",
            attributes: {
                propertyValue: "testValue"
            },
            state: {
                c__id: "test"
            }
        };
    }

I have already tried this and got Action failed: c:TestAuraComponent$controller$getLabel [undefined is not an object (evaluating 'myLabel.state')]:

getLabel : function(component, event, helper) {
    var myLabel = component.get("v.MobileNavigation");
    myLabel = myLabel.state.c__id;  
    component.set("v.buttonLabel", myLabel);
},

I suspect I am entering the wrong argument for cmp.get(), I have also tried ("v.compDefinition").

Update1: I realized that pageReference is a special type of attribute and we don't have to create an attribute with the name pageReference. I changed it to var myLabel = component.get("v.pageReference"); and still I am getting undefined for myLabel.state

Update2: added this[NavigationMixin.Navigate](compDefinition); to invoke the method, still no luck

Update3: I can render a string like myLabel = 'hello world'; just not myLabel.state. Looks like the problem is getting the state/attribute values.

2
  • 1
    Does your aura implements isUrlAddressable interface? Dec 21, 2021 at 3:35
  • @SachinHooda I added implements="flexipage:availableForAllPageTypes,lightning:isUrlAddressable" and it seems to be working. Thanks
    – ApexCowboy
    Dec 21, 2021 at 4:50

0

You must log in to answer this question.