@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 ofsomeProps
are NOT empty. But an infinite loop occurs when BOTH of the previous and current values ofsomeProps
are empty arrays.Any suggestion would be much appreciated! Thank you!
Posts: 1
Participants: 1