I have this error when trying to dynamically create a component, where the first time it runs it runs okay but if run again afterward it errors.
renderListItems: function (cmp, helper, recordIds) {
if (typeof recordIds === 'undefined') {
recordIds = cmp.get('v.recordIds');
}
else{
cmp.set('v.recordIds',recordIds);
}
let renderedComponents = [];
let componentName = 'c:' + cmp.get('v.itemComponent'); //c:Posting_JobItem
cmp.set("v.renderedComponents", renderedComponents);
for(let i = 0;i < recordIds.length;i++){
let recordId = recordIds[i];
console.log(recordId);
console.log(componentName);
$A.createComponent(
componentName, {
"recordId": recordId
},
function (newItem, status, errorMessage) {
console.log(newItem);
//Add the new button to the body array
if (status === "SUCCESS") {
renderedComponents.push(newItem);
cmp.set("v.renderedComponents", renderedComponents);
} else if (status === "INCOMPLETE") {
console.log("No response from server or client is offline.")
} else if (status === "ERROR") {
console.log("Error: " + errorMessage); //outputs - 'Error: Unknown component 'markup://c:Posting_JobItem'
}
}
);
}
}
When this runs during init it completes happily. But when run again (with the same or different recordIds) I get an error that says 'Error: Unknown component 'markup://c:Posting_JobItem'