I have a LWC which is doing some conditional display. The LWC is encapsulated in a Lightning Component and receives a record id from it. When opening the parent Lightning Component for different records one after the other, the content is cached and it displays the content corresponding to the first record for all subsequent records.
The conditional display calculations are performed in the connectedCallback method, but it seems like the second time I open the Lightning component, connectedCallback is not executed at all.
As a note, Enable secure and persistent browser caching to improve performance is disabled in Session Settings.
How can I avoid this?
Edit: Here is the relevant piece of code to reproduce this: AuraContainer.cmp:
<aura:component implements="lightning:isUrlAddressable,force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId">
<c:sendemail onshowtoast="{!c.handleShowToast}"/>
</aura:component>
SendEmail LWC:
import { LightningElement, api, wire } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
import checkOrgValidity from '@salesforce/apex/SendEmailController.checkOrgValidity'
import { ShowToastEvent } from 'lightning/platformShowToastEvent'
export default class SendEmail extends LightningElement {
@api recordId;
// Injects the page reference that describes the current page
@wire(CurrentPageReference)
currentPageReference;
async connectedCallback() {
// the log is only displayed on the first load of the lightning component
console.log('connectedCallback');
this.recordId = this.currentPageReference.state.c__recordId;
checkOrgValidity({sId: this.recordId})
.then(result => {
// processing in case of success
})
.catch(error => { });
}
}
The Lightning component gets opened using a Detail Page Button:
Behavior: Display in existing window with sidebar
Button or Link URL: /lightning/cmp/c__SendEmailContainer?c__recordId={!Account.Id}