I have a custom lwc that navigates to an aura and it's working fine but whenever I change the url parameters the onPageReference method from the aura is not working.
This is my lwc code:
this[NavigationMixin.Navigate]({
type : 'standard__component' ,
attributes : {
componentName : 'c__MyAuraComponent'
},
state : {
c__previousPageReference : //previous page reference,
c__question : //object,
c__questionId : //id
}
});
And this is my aura:
cmp:
<aura:handler name="change" value="{!v.pageReference}" action="{!c.onPageReferenceChange}"/>
controller.js:
onPageReferenceChange: function(component, event, helper) {
console.log('**reference has changed');
helper.managePageReference(component);
},
But I'm not being able to get the console log.
Is there something I'm doing wrong?
Regards,
EDIT My aura also has a onInit handler and both onInit and onPageReferenceChange call the same helper method for data retrieve based on url:
cmp:
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:handler name="change" value="{!v.pageReference}" action="{!c.onPageReferenceChange}"/>
controller.js: onPageReferenceChange: function(component, event, helper) { console.log('**reference has changed', component.get("v.pageReference")); helper.managePageReference(component); }, doInit: function (component, event, helper) { helper.managePageReference(component); },
helper.js:
managePageReference: function (component, event) {
var myPageRef = component.get("v.pageReference");
if(myPageRef && myPageRef.state){
Object.keys(myPageRef.state).forEach(key => {
let fixedKey = key.split('c__').pop();
component.set("v." + fixedKey, myPageRef.state[key]);
});
}
},