Jan 4, 2021

Decorators

 Decorators

Decorators

Decorators are often used in JavaScript to modify the behavior of a property or function.
@api: Marks a field as public. Public properties define the API for a component. An owner component that uses the component in its HTML markup can access the component’s public properties.
All public properties are reactive, which means that the framework observes the property for changes. When the property’s value changes, the framework reacts and rerenders the component.
@track: Tells the framework to observe changes to the properties of an object or to the elements of an array. If a change occurs, the framework rerenders the component.
Prior to Spring ’20, you had to use @track to mark fields (also known as private properties) as reactive. You’re no longer required to do that. Use @track only to tell the framework to observe changes to the properties of an object or to the elements of an array. Some legacy examples may still use @track where it isn’t needed, but that’s OK because using the decorator doesn’t change the functionality or break the code. For more information, see this release note.
@wire: Gives you an easy way to get and bind data from a Salesforce org.

No comments:

Post a Comment