Professional Documents
Culture Documents
LWC BEST PRACTICE
LWC BEST PRACTICE
sweety kumari
LWC Component Bundle Naming Convention:
Component Bundle:
Use camelCase: Name your component
bundles using camelCase.
Example: myComponent
HTML File:
Use camelCase: Name the HTML file
using camelCase to match the component
bundle name.
sweety kumari
Use kebab-case: Reference the component
in the markup using kebab-case.
Example: For a component bundle named
myComponent, the HTML file is
myComponent.html and referenced as <c-my-
component></c-my-component>.
JavaScript File:
Use PascalCase: Name the JavaScript class
in PascalCase.
Example: For a component bundle named
myComponent, the JavaScript file is
myComponent.js with a class named
MyComponent.
sweety kumari
Modular Architecture:
sweety kumari
Use @wire for Reactive Properties:
sweety kumari
Import Object & Field References:
Example:
import { LightningElement, wire } from 'lwc';
import ACCOUNT_OBJECT
from'@salesforce/schema/Account';
import NAME_FIELD from
'@salesforce/schema/Account.Name';
import getAccountList from
'@salesforce/apex/AccountController.getAccountList';
@wire(getAccountList)
accounts;
}
sweety kumari
Error Handling:
Implement robust error handling for Apex
calls and data operations.
Use try-catch blocks and user-friendly error
messages.
sweety kumari