Skip to main content

Posts

Showing posts from July, 2023

Enable reactivity in lwc:spread (LWC)

With the introduction of Salesforce Summer '23 release, a new feature for LWC components called lwc:spread became available. This feature enables us to spread properties on child components. Although the documentation provides instructions on its usage, ensuring the spread feature's reactivity is essential to fully leverage its capabilities. In this article, we will delve into examples of a parent component and a nested child component to grasp how to achieve reactivity for maximum usability. The lwc:spread directive allows accepting a single object with key-value pairs, where the keys represent property names. In the example below, we demonstrate how to use this feature to spread properties on child components: <!-- app.html --> <template>     <c-child lwc:spread={childProps}></c-child> </template> In this case, the parent component sets an object called "childProps" with properties "name" and "country" having values...