I am currently using LCC npm module (Lightning Container) to make Apex calls in our React app.
However, we are also exploring cutting out LCC altogether (the concern is that it has not been updated in 4 years), as our app is currently in a lighting web component iframe wrapped in an aura parent div. Since aura components can speak directly to apex, I am using a callback to get the actual data I need from Apex. However, the data does not update on the static resource. Is there a way to do this?
//.cmp
<aura:component controller="ContactController" implements="force:hasRecordId,flexipage:availableForAllPageTypes" access="global" >
<aura:attribute name="recordId" type="String" />
<aura:handler name="init" value="{!this }" action="{!c.doInit }"/>
<lightning:container src="{!$Resource.demo_salesforce_hello + '/index.html?recordid=' + v.recordId}" onerror="{!c.handleError}"/>
</aura:component>
//.js
doInit : function(component, event, helper) {
//var recordId = component.get('v.recordId');
var action = component.get("c.serverEcho");
action.setParams({recordId : component.get('v.recordId') });
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
console.log("From server: " + JSON.stringify(response.getReturnValue()));
component.set("v.recordId", JSON.stringify(response.getReturnValue()));
}
else if (state === "INCOMPLETE") {
// do something
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
} else {
console.log("Unknown error");
}
}
});
$A.enqueueAction(action);
}
//apex
@AuraEnabled(cacheable=true)
public static Contact[] serverEcho(String recordId) {
String contactId = [SELECT ContactId FROM Case WHERE Id= :recordId].ContactId;
System.debug([SELECT Id, Name, LOB__c, PlanName__c FROM Contact WHERE Id= :contactId]);
return [SELECT Id, Name, LOB__c, PlanName__c FROM Contact WHERE Id= :contactId];
}