# LWC1097
Represents a wire adapter identifier error.
Severity: Error
# Message
@wire expects a function identifier as first parameter.
# Problem
LWC1097 occurs when the first parameter to the @wire decorator isn't a function identifier (a simple identifier or member expression). The @wire decorator requires its first parameter to be an imported wire adapter reference that can be statically analyzed.
# Examples
Review these examples to help you resolve error code LWC1097.
# 1. Invalid Wire Adapter Identifier
LWC1097 occurs when the first parameter to the @wire decorator isn't a valid function identifier. The @wire decorator requires its first parameter to be either:
- A simple identifier, such as
getRecord - A member expression with one level of nesting, such as
Adapters.getRecord
Both forms must reference an imported wire adapter function. The compiler must be able to statically analyze which adapter is being used to set up reactive data binding properly.
Invalid parameter types include:
- Function expressions or arrow functions — Inline function definitions can't be used because the wire adapter must be imported and statically identifiable
- Literal values — Strings, numbers, or booleans aren't valid even if they contain an adapter name; an actual function reference is required
- Complex expressions — Objects, arrays, or other complex expressions can't be statically analyzed to determine the wire adapter being used
# Examples with Errors
Here are several examples that return error code LWC1097.
Using a function expression:
import { wire, LightningElement } from 'lwc';
export default class TestComponent extends LightningElement {
@wire(function adapter() {}) wiredProp;
}
Error Message:
LWC1097: @wire expects a function identifier as first parameter.
Using a string literal:
import { wire, LightningElement } from 'lwc';
export default class TestComponent extends LightningElement {
@wire('getAdapter') wiredProp;
}
Error Message:
LWC1097: @wire expects a function identifier as first parameter.
Using an object literal:
import { wire, LightningElement } from 'lwc';
export default class TestComponent extends LightningElement {
@wire({adapter: 'getRecord'}) wiredProp;
}
Error Message:
LWC1097: @wire expects a function identifier as first parameter.
# Error Resolution Examples
Here are several ways to fix error code LWC1097.
Use a simple identifier:
import { wire, LightningElement } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
export default class TestComponent extends LightningElement {
@wire(getRecord, { recordId: '$recordId' }) wiredProp;
}
Use a member expression for namespaced adapters:
import { wire, LightningElement } from 'lwc';
import { Adapters } from 'my-data-service';
export default class TestComponent extends LightningElement {
@wire(Adapters.getRecord, { recordId: '$recordId' }) wiredProp;
}
# LWC1097 Suggested Fix Steps
Consider these suggestions to fix LWC1097 errors.
# Step 1: Identify Your Wire Adapter
Determine which wire adapter you need for your use case. Common wire adapters include:
getRecordfromlightning/uiRecordApi— Retrieves a recordgetObjectInfofromlightning/uiObjectInfoApi— Retrieves object metadata- Custom Apex methods decorated with
@wireannotation
# Step 2: Import the Adapter
Add an import statement at the top of your component file to import the wire adapter:
import { getRecord } from 'lightning/uiRecordApi';
For custom Apex wire adapters:
import { getDataFromServer } from '@salesforce/apex/MyController.getDataFromServer';
# Step 3: Use the Imported Identifier
Replace any inline functions, literals, or complex expressions with the imported identifier:
Before:
@wire('getRecord') wiredData;
After:
import { getRecord } from 'lightning/uiRecordApi';
// ...
@wire(getRecord) wiredData;
# Step 4: Add Configuration (Optional)
If your wire adapter accepts a configuration object as the second parameter, you can add it after the adapter reference:
@wire(getRecord, { recordId: '$recordId', fields: ['Account.Name'] })
wiredData;