All the best,
Well, my problem is when implementing the events (OnChanges, DoCheck) in my component and it's fine, but when executing the "ng lint" command I get an error that these events are not well declared or implemented, so I have structured the events in my component but I get an error, so my question is if I'm doing something wrong or is there another way to implement them:
ERROR:
18:43 error Implementing DoCheck and OnChanges in a class is not recommended @angular-eslint/no-conflicting-lifecycle
18:52 error Implementing DoCheck and OnChanges in a class is not recommended @angular-eslint/no-conflicting-lifecycle
68:3 error Declaring ngDoCheck and ngOnChanges method in a class is not recommended @angular-eslint/no-conflicting-lifecycle
125:3 error Declaring ngDoCheck and ngOnChanges method in a class is not recommended @angular-eslint/no-conflicting-lifecycle
CODIGO:
import {
Component, DoCheck, EventEmitter, Input, IterableDiffers, OnChanges,
Output, SimpleChange
} from '@angular/core';
export class DualListComponent implements DoCheck, OnChanges {
...
}
ngOnChanges(changeRecord: { [key: string]: SimpleChange }): void {
...
}
ngDoCheck(): void {
...
}
CodePudding user response:
When the default change detector detects changes, it invokes ngOnChanges() if supplied, regardless of whether you perform additional change detection. Typically, you should not use both DoCheck and OnChanges to respond to changes on the same input.
https://angular.io/api/core/DoCheck#usage-notes
It is just enforcing the recommendation from Angular not to implement these together in the same component.