Decorators : | ‹ | › |
There are three types of decorators :
1. @track
2. @api
3. @wire
@track : It is used to make properties or methods in LWC is private. This properties is not accessible outside the LWC in which it is declared.
@api : It is used to make properties or methods in LWC is public. This way they are accessible outside of the component in which they are declared.
For ex : parent component can set the value of the properties in the child component.
@wire : It is used to read the Salesforce data from apex class into LWC. It is generally used while making the server call to apex class.
LWC Properties :
There are two type of LWC properties.
1. Reactive Properties
2. Non-Reactive Properties
Reactive Properties : In case of reactive properties , value of the properties change when the component re-render. There are two types of Reactive Properties.
1. Public properties - Decorated with @api.
2. Private properties - Decorated with @track.
Non-Reactive Properties : Non-Reactive properties are declared without any decorators , so even if the value of the non-reactive properties changes component doesn't get re-render.
Comments
Post a Comment