When component is loaded in lightning experience, we can get the state of page ref using below:
doInit : function(component, event, helper) {
let pr = component.get("v.pageReference");
if(pr)
component.set("v.attr",pr.state.c__myAttr);
}
We are able to navigate to a custom page in community using below page reference.
{
type: "comm__namedPage",
attributes: {
pageName: "custom-page"
},
state: {
c__myAttr: "some value"
}
}
Also we are getting the parameters in URL like /s/custom-page?c__myAttr=some+value
However, we have the component inside the custom page which is not able to get the page ref state parameters.
I know that we can get url through window.location.href
and get parameter out of it. But is there a standard way of lightning component in custom page to get page ref and its state?