diff --git a/projects/ngx-turnstile/src/lib/ngx-turnstile.component.ts b/projects/ngx-turnstile/src/lib/ngx-turnstile.component.ts index d650c49..2ea17d1 100644 --- a/projects/ngx-turnstile/src/lib/ngx-turnstile.component.ts +++ b/projects/ngx-turnstile/src/lib/ngx-turnstile.component.ts @@ -102,6 +102,8 @@ export class NgxTurnstileComponent implements AfterViewInit, OnDestroy { } public ngOnDestroy(): void { - window.turnstile.remove(this.widgetId); + if (this.widgetId) { + window.turnstile.remove(this.widgetId); + } } }