I am trying to import a custom object and I am getting the following error
'LWC1513: @salesforce/schema modules only support default imports'
here is my code for my js file.
import { LightningElement,api } from 'lwc';
import { StreetAddress } from "@salesforce/schema/Retail_Account__c.Address__c";
import { CityAddress } from "@salesforce/schema/Retail_Account__c.City__c";
import { StateAddress } from "@salesforce/schema/Retail_Account__c.State__c";
import { RetalName } from "@salesforce/schema/Retail_Account__c.Name"
export default class RetailMapSingleMarker extends LightningElement {
@api RecordId
@api objectApiName
mapMarkers = [
{
location: {
Street: StreetAddress,
City: CityAddress,
State: StateAddress,
},
title: RetalName
,
},
];
}
Best Answer
When you say
import { RetalName }
- this is called Named Import. This is not valid for @salesforce/schema modules since they are default exports. You need to use below:This means, you are importing default
Retail_Account__c.Name
and assigning it to variableRETAIL_ACCOUNT_NAME
.NOTE:
You can use Named imports for a module like below:
Here, you are exporting getTermOptions and calculateMonthlyPayment functions. So, you can import them by Name as below.