Lightning web components best practices
1. Use proper Naming conventions while creating lightning web components.
- Must begin with a letter
- Must contain only alphanumeric or underscore characters
- Must be unique in the namespace
- Can’t include whitespace
- Can’t end with an underscore
- Can’t contain two consecutive underscores
- Can’t contain a hyphen (dash)
- use camelCase format, start the component name from lowercase
- Ex: helloWorld
HTML file:
[<template>js file:
<h1>{title}</h1>
</template>]
[import { LightningElement } from 'lwc';
export default class HelloWorld extends LightningElement {
title ='Hello world';
}]
COMMENTS