0

I have defined two LWC's one is Reactive & other is non reactive .So NOn reactive component should not rerender its values ,But both the LWC's reredenring property values.Let me know what is the issue in my code Below is my code. 1html code:

<template>
    <table style="background: white;">
        <tr>
            <td>
                Reactive Private property
                <lightning-input type="text" onchange={changeHandler1}></lightning-input>
                <br/>
                <b>value: {reactivePrivateProperty}</b>
            </td>
        </tr>
        <tr>
           <td>
                Non Reactive Private property
                <lightning-input type="text" onchange={changeHandler2}></lightning-input>
                <br/>
                <b>value: {nonReactivePrivateProperty}</b>
           </td>
        </tr>

    </table>
</template>

[2]JS code:


import { LightningElement,track} from 'lwc';

export default class PrivateComponent extends LightningElement {
    @track reactivePrivateProperty;
    nonReactivePrivateProperty;

    changeHandler1(event)
    {
        this.reactivePrivateProperty= event.target.value;
    }

    changeHandler2(event)
    {
        this.nonReactivePrivateProperty=event.target.value;
    }

}

[3] css code

table tr td{
    padding:10px;
    border:1px solid black;
}

[4] xml code:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="privateComponent">
    <apiVersion>46.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__HomePage</target>
    </targets>
</LightningComponentBundle>

[5]Image is attached : SFDC UI enter image description here

1
  • All the class attributes are track. track decorator used only for non primitive data type. – Ranjith U K May 25 '20 at 7:57
2

All fields in a Lightning web component class are reactive from Spring ’20.
Refer here

2
  • Just Reconfirming So no more non reactive components – AM_SFDC May 26 '20 at 7:23
  • yes, for primitive data types (String, Number, and Boolean). However, for Composite data types like Array, the elements are reactive only if @track is used. – ssoundiran May 26 '20 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.