Skip to content
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

ViewDestroyedError: Attempt to use a destroyed view: detectChanges #106

Open
BojanKogoj opened this issue May 7, 2021 · 1 comment
Open

Comments

@BojanKogoj
Copy link

BojanKogoj commented May 7, 2021

I managed to get this exception in LocalizeRouterPipe, but hard to reproduce.

exception

With current implementation

if (view && (view.state & VIEW_DESTROYED_STATE)) {
return this.value;
}
setTimeout(() => {
this._ref.detectChanges();
}, 0)

I can only assume it was destroyed while in setTimeout. This was introduced in 851563a.

I suggest we check if view was destroyed before calling .detectChanges() stackoverflow

setTimeout(() => {
  if (this._ref && !(this._ref as ViewRef).destroyed) {
    this._ref.detectChanges();
  }
}, 0)
@gilsdav
Copy link
Owner

gilsdav commented May 26, 2021

Is it compatible with and without Ivy ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants