I'm trying to understand better how ChangeDetection is working and I have a question related to this.
If I'm using changeDetection: ChangeDetectionStrategy.OnPush
, on ngOnChanges
lifecycle hook I need to verify also if currentValue
exists? Or it's enough to verify if the input was changed ?
I can give you an example to understand better what I'm talking about:
So, as I mentioned, I'm using changeDetection: ChangeDetectionStrategy.OnPush
and this is my input @Input() isInspectionReopened: boolean;
and ngOnChanges
looks like this:
ngOnChanges(changes: SimpleChanges) {
if(changes.isInspectionReopened) {
// do something
}
}
It's enough to verify changes.isInspectionReopened
or I need to add changes.isInspectionReopened.currentValue
?