I am using lightning navigation to pass recordId
from the parent component to the child component.
On button click, I am navigating to child component like below URL -
https://XXXXXXXXXX.lightning.force.com/lightning/cmp/c__ChildComp?c__recordId=t2B9E000123JvDJUA0
I need to get the recordId
from the URL in the child component and pass it to apex methods.
I tried the below, but did not get the recordId
.
import { LightningElement, api, track, wire } from "lwc";
import { getRecord, generateRecordInputForUpdate } from "lightning/uiRecordApi";
import { CurrentPageReference } from "lightning/navigation";
export default class TestLWC extends LightningElement {
@track getrecordId;
@wire(CurrentPageReference)
currentPageReference;
setCurrentPageReference(currentPageReference) {
this.currentPageReference = currentPageReference;
}
getrecordId =
this.currentPageReference && this.currentPageReference.state.c__recordId
@wire(getData, { getrecordId: "$getrecordId" })
}
setCurrentPageReference(currentPageReference) {this.currentPageReference = currentPageReference; .....}