-
Notifications
You must be signed in to change notification settings - Fork 64
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
Check null for subscriptions in ngOnDestroy #79
Conversation
In a scenario I got below error: core.mjs:6397 ERROR TypeError: Cannot read properties of undefined (reading 'forEach') at KtdGridComponent.ngOnDestroy (katoid-angular-grid-layout.mjs:1612:28)
@@ -325,7 +325,7 @@ export class KtdGridComponent implements OnChanges, AfterContentInit, AfterConte | |||
} | |||
|
|||
ngOnDestroy() { | |||
this.subscriptions.forEach(sub => sub.unsubscribe()); | |||
this.subscriptions?.forEach(sub => sub.unsubscribe()); |
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.
What about initializing subscriptions as an empty array?
private subscriptions: Subscription[] = []
Seems cleaner since it will always be an array of Subscriptions.
Nice @ravanjamjah 👌 . I added a small comment proposing initializing It will also be nice if you change the commit text to conventional commits. For example:
Thanks! |
What is the status of this PR ? I encounter the same issue |
I fixed the problem in our project. |
Glad for you ;) On our side, I was able to workrounded the issue by removing a |
Thanks, exactly as I did, I fixed with a *ngIf. |
Maybe. How to reproduce the problem:
In the component B, depending of the urls, there were a It was not a correct design for routing (even if it would work as is) so I fully rework this and it work around the grid issue. The new routing completely get rid of any display logic (the Hope it can helps |
In a scenario I got below error:
core.mjs:6397 ERROR TypeError: Cannot read properties of undefined (reading 'forEach')
at KtdGridComponent.ngOnDestroy (katoid-angular-grid-layout.mjs:1612:28)