{"id":6342,"date":"2021-09-24T07:43:17","date_gmt":"2021-09-24T07:43:17","guid":{"rendered":"https:\/\/www.greytrix.com\/blogs\/salesforce\/?p=6342"},"modified":"2021-09-24T07:43:18","modified_gmt":"2021-09-24T07:43:18","slug":"the-track-decorator-is-no-longer-required-for-lightning-web-component-but-with-one-exception","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/09\/24\/the-track-decorator-is-no-longer-required-for-lightning-web-component-but-with-one-exception\/","title":{"rendered":"The @track Decorator Is No Longer Required for Lightning Web Component but with one Exception"},"content":{"rendered":"\n<p>We are referring here to <strong>Spring \u201920 Release Notes<\/strong> available on the <a rel=\"noreferrer noopener\" href=\"https:\/\/help.salesforce.com\/s\/articleView?id=release-notes.rn_lwc_track.htm&amp;type=5&amp;release=224\" data-type=\"URL\" data-id=\"https:\/\/help.salesforce.com\/s\/articleView?id=release-notes.rn_lwc_track.htm&amp;type=5&amp;release=224\" target=\"_blank\">Salesforce help section<\/a>. <\/p>\n\n\n\n<p>We have removed the @track decorator from all the variables in our test project, but it was not working for the few variables.<\/p>\n\n\n\n<p>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\u2019s see the below code example,<\/p>\n\n\n\n<p>Here we are returning object wrapper from apex code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>AccountDTWrapper objDT =  new AccountDTWrapper();  \r\nobjDT.pageSize = pageSize;\r\nobjDT.pageNumber = pageNumber;\r\nobjDT.recordStart = offset + 1;\r\nobjDT.totalRecords = totalRecords;\r\nobjDT.account=&#91;select Id,Name from Account limit 10];\r\nreturn objDT;\r<\/code><\/pre>\n\n\n\n<p>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.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Component rerenders.\r\n@track result;\r\nthis.result. recordStart  = 10; \r<\/code><\/pre>\n\n\n\n<p>We hope to use the information, and you can use the <strong>@track<\/strong> decorator object to its optimum use.<\/p>\n\n\n\n<p>We hope you may find this blog resourceful and helpful. If you still have concerns and need more help, don\u2019t hesitate to get in touch with us at\u00a0<a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>.<\/p>\n\n\n\n<p style=\"text-align: justify\"><b>About Us<\/b><\/br>\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> \u2013 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.<br><br> Greytrix has some unique solutions for Cloud CRM such as <a href=\"\">Salesforce Sage integration<\/a> for <a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/integration\/\">Sage X3<\/a>, <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/sage-100-integration\/\">Sage 100<\/a> and <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/sage-300-integration\/\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/crm-development\/\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/data-migration-support\/\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/crm-development\/\">Integrated App development<\/a>, Custom App development and Technical Support business partners and end users. Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star rated app listed on <a href=\"https:\/\/appexchange.salesforce.com\/appxListingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<br> The GUMU&#x2122; 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.<br><br> For more information on our Salesforce products and services, contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n\n\n\n<p><strong>Related Posts<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/09\/22\/how-to-use-email-template-in-apex-code\/\" data-type=\"URL\" data-id=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/09\/22\/how-to-use-email-template-in-apex-code\/\" target=\"_blank\">How to Use Email Template in Apex Code<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/08\/16\/clone-record-of-any-object-using-flows-in-salesforce\/\" target=\"_blank\">Clone Record of Any Object using Flows in Salesforce<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/08\/14\/how-to-avoid-null-pointer-exception-by-using-safe-navigator-operator\/\" target=\"_blank\">How to Avoid Null Pointer Exception By Using Safe Navigator Operator (?.)<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/08\/17\/how-to-create-a-dynamic-multi-filter-object-in-salesforce-part-i\/\" target=\"_blank\">How to create a dynamic multi-filter object in Salesforce-Part I<\/a><\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We are referring here to Spring \u201920 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,\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/09\/24\/the-track-decorator-is-no-longer-required-for-lightning-web-component-but-with-one-exception\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1206,1179,206,207,208,1050,1049,1178,651],"class_list":["post-6342","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-track-decorator","tag-key-code","tag-lightning","tag-lightning-basics","tag-lightning-component","tag-lightning-web-component","tag-lwc","tag-lwc-key-event","tag-salesforce-lightning-component"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/6342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=6342"}],"version-history":[{"count":1,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/6342\/revisions"}],"predecessor-version":[{"id":6343,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/6342\/revisions\/6343"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=6342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=6342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=6342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}