I have an LWC utility class that imports custom labels and exports, ex.
import customLabelOne from '@salesforce/label/c.customLabelOne';
import customLabelTwo from '@salesforce/label/c.customLabelTwo';
export const customLabels = {
customLabelOne = customLabelOne,
customLabelTwo = customLabelTwo
}
This works fine if I import the object into another LWC. However, now I want to use the utility class in Aura components also. So far, I have done this in the .cmp file:
<c:customLabelsUtils aura:id="utils" />
And then in the helper of the Aura, I'm trying to do something like this:
getCustomLabelsUtils : function(component,event,helper){
var libCmp = component.find('utils');
const customLabels = libCmp.customLabels;
console.log('customLabels type is => ' + typeof(customLabels));
console.log('customLabels is => ' + customLabels);
console.log('customLabels.customLabelOne => ' + customLabels.customLabelOne);
},
Which prints out the following:
customLabels type is => function
customLabels is => function [object Object]() { [native code] }
customLabels.customLabelOne => undefined
How do I get the labels in the Aura component?