New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set a property with an array in a component will hang up everything #12644
Comments
BTW, I often see some deprecations to tell me not to modify property during Components often need DOM calculations and depends on itself is actually rendered, if some property needs to be re-computed with its DOM changes (like height/width, position etc.), why can't do these in |
Setting an array to a property shouldn't be a problem at all. Maybe you have observer somewhere, which also modifying the |
@ptgamr No, I can confirm there's only one place to set |
Ok I see :) I mangage to put a twiddle here: https://ember-twiddle.com/e916bd0c7d9ca46198f8 Setting the property on For example: on didRender --> you update the property --> then the view updated --> didRender hook again.... |
@ptgamr I understand your explanation, I actually thinking in this way at first, but later I change the
and the problem is gone... why this works? this still set property(ies), instead of set one property with an array, I set two properties. It doesn't make any sense. |
@ptgamr with your inspiration, I made some test: // instead of setProperties
// this.setProperties({ thresholdX, thresholdY });
// set them individually
this.set('thresholdX', thresholdX);
this.set('thresholdY', thresholdY); this works fine, but if you change // set them as an array
this.set('thresholdX', [thresholdX]);
this.set('thresholdY', [thresholdY]); infinite call again...now I'm pretty sure |
I'm guessing this is because if you set a property to the same as its current value it doesn't trigger change notifications. When you set it to an array, With primitives, this won't happen because it'll notice it's the same as before and so doesn't end up re-rendering the 2nd time. |
I've encounter a weird problem, I try to reproduce it with ember-twiddle but let me explain it first.
In a component's
didRender
hook, I need to calculate some DOM related data and expose it to the nested components, so I did something like below:As commented above, set with an array will repeatedly throw deprecations crazily:
I try to use ember-twiddle to reproduce it, but since it will hang the browser up, so I can't save it to share.
Ember v2.2.0
The text was updated successfully, but these errors were encountered: