-
Notifications
You must be signed in to change notification settings - Fork 353
Avoid "update prop already used in computation" #802
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import Component from '@ember/component'; | ||
|
|
||
| import { run } from '@ember/runloop'; | ||
| import { computed } from '@ember/object'; | ||
| import { observer } from '../../-private/utils/observer'; | ||
| import { bool, readOnly, or } from '@ember/object/computed'; | ||
|
|
@@ -234,7 +235,9 @@ export default Component.extend({ | |
| */ | ||
| canSelect: bool('onSelect'), | ||
|
|
||
| 'data-test-row-count': readOnly('wrappedRows.length'), | ||
| dataTestRowCount: null, | ||
|
|
||
| 'data-test-row-count': readOnly('dataTestRowCount'), | ||
|
|
||
| init() { | ||
| this._super(...arguments); | ||
|
|
@@ -297,7 +300,7 @@ export default Component.extend({ | |
|
|
||
| /** | ||
| Computed property which updates the CollapseTree and erases caches. This is | ||
| a computed for 1.11 compatibility, otherwise it would make sense to use | ||
| a computed for 1.12 compatibility, otherwise it would make sense to use | ||
| lifecycle hooks instead. | ||
| */ | ||
| wrappedRows: computed('rows', function() { | ||
|
|
@@ -306,6 +309,11 @@ export default Component.extend({ | |
| this.collapseTree.set('rowMetaCache', this.rowMetaCache); | ||
| this.collapseTree.set('rows', rows); | ||
|
|
||
| run.schedule('actions', () => { | ||
| // eslint-disable-next-line ember-best-practices/no-side-effect-cp | ||
| this.set('dataTestRowCount', this.get('wrappedRows.length')); // eslint-disable-line ember/no-side-effects | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this passes the test then LGTM but obviously this super sucks explicitly adding this sideeffectyness. Thankfully it's pretty limited side effect but still 🤢
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, as noted this is expanding on an already-existing side effect which caused the problem. An alternative here would be to simply stop offering the |
||
| }); | ||
|
|
||
| return this.collapseTree; | ||
| }), | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need two
eslint-disablecomments here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are indeed two rules which error on this.
It is actually a bit annoying since the side effects really begin on line 309, but I presume the lint only catches on
this.set