The @track Decorator Is No Longer Required for Lightning Web Component but with one Exception

By | September 24, 2021

We are referring here to Spring ’20 Release Notes available on the Salesforce help section.

We have removed the @track decorator from all the variables in our test project, but it was not working for the few variables.

After more detail, we found one exception while removing the @track decorator, i.e., when using objects. So, if we change the property of an object, it will not render the same on UI. Unless the object variable is not having a @track decorator. Let’s see the below code example,

Here we are returning object wrapper from apex code.

AccountDTWrapper objDT =  new AccountDTWrapper();  
objDT.pageSize = pageSize;
objDT.pageNumber = pageNumber;
objDT.recordStart = offset + 1;
objDT.totalRecords = totalRecords;
objDT.account=[select Id,Name from Account limit 10];
return objDT;

Firstly, if you change any value of the wrapper object here in this js file, it will not reflect on UI if the @track decorator is not used. So I have used the @track decorator for datatypes of the object type.

// Component rerenders.
@track result;
this.result. recordStart  = 10; 

We hope to use the information, and you can use the @track decorator object to its optimum use.

We hope you may find this blog resourceful and helpful. If you still have concerns and need more help, don’t hesitate to get in touch with us at salesforce@greytrix.com.

About Us
Greytrix – a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce Sage integration for Sage X3Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data MigrationIntegrated App developmentCustom App development and Technical Support to business partners and end users.
Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star rated app listed on Salesforce AppExchange.

The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.

For more information on our Salesforce products and services, contact us at salesforce@greytrix.com. We will be glad to assist you.

Related Posts