polymerweb-componentlit-elementlit-html

Where is the state and setState lit-element?


Coming from a react background, i was wondering where is the state and setState equivalent in lit-element, i couldn't find anything useful in lit-element docs. is it private property? or requestUpdate?


Solution

  • There is no state in LitElement, at least not directly.

    What you have is a set of properties that you define in the static get properties() getter.

    They act more or less like state does in rect, everytime one of those properties change, the element is updated.