Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4836

How does Ember decide whether to update components under the hood?

$
0
0

@Liutong wrote:

For some reason, our project is setting a component’s props inside didRender function, which would trigger another rerender based on the lifecycle of Ember component. But this hasn’t ended up in an infinite loop except when the previous prop and new prop are both empty arrays. May I know why is that? Could it be related to the way Ember is comparing/updating components under the hood?

someComponent.hbs

{{someComponent
    someProps=DS.attr() // THIS IS AN ARRAY
 }}

someComponent.js

didRender() {
    const newProps = ['newValue'];
    this.set('someProps', newProps)
}

So the above example works as excepted ( render -> didRender -> updateProps -> rerender -> didRender -> stop ) when both or either of the previous or current values of someProps are NOT empty. But an infinite loop occurs when BOTH of the previous and current values of someProps are empty arrays.

Any suggestion would be much appreciated! Thank you!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4836

Trending Articles