Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/slick.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ export class SlickCarouselComponent implements OnDestroy, OnChanges, AfterViewIn
this.initialized = false;
}

// Added a check to ensure that this.$instance is defined before accessing it to prevent TypeError: Cannot read properties of undefined (reading 'slick')
// This helps prevent errors when ngOnChanges() is called and ensures that the Slick Carousel component is properly initialized before accessing its properties.
ngOnChanges(changes: SimpleChanges): void {
if (this.initialized) {
if (this.initialized && this.$instance) {
const config = changes['config'];
if (config.previousValue !== config.currentValue && config.currentValue !== undefined) {
const refresh = config.currentValue['refresh'];
Expand Down