vendredi 16 septembre 2022

Difference between and in Ember JS

When I use did-update without wrapping using <div>, the action using in did-update fall into infinite loop. After wrapping with <div>, the problem has solved.

Here's an example code: (current is service which shows the current status)

Does not work: (when this.current.locationId changed, this.updateStates be executed infinitly)


Does work:

<div >
</div>

JS file:

@tracked property;

@action
updateStates() {
  //do something with `this.current.locationId`
  //change value of `property`
  //so template re-render cause of `property` changed
  ...
}

I guess the problem happens because of the tracking frame. But I can not exactly see why that kind of problem is happening.




Aucun commentaire:

Enregistrer un commentaire