0

I want to do the following:

When the property "mobile" is changed, check to see if X is true, if so, set set a variable Y and call requestUpdate to re-render the element. The element will render something different based on variable X.

so shouldUpdate function could be:

shouldUpdate(changedProperties) {
   if (changedProperties.has("mobile")) {
       this._showDialog = true;
       this.requestUpdate();
       await this.updateComplete;
   }
   return this.openingDialog;
}

What's the best way to do this without using the shouldUpdate function?

Chris Hansen
  • 7,813
  • 15
  • 81
  • 165

1 Answers1

1

You can use willUpdate to compute Y variable. willUpdate used to compute values needed during the update.

willUpdate(changedProperties) {
  if (changedProperties.has("mobile")) {
    this._showDialog = true;
  }
}
Hiten B
  • 61
  • 1
  • 12