Skip to content

Ionic v2 - Loading component throw error when trying to present after dismiss #6462

@lricoy

Description

@lricoy

Short description of the problem:

If you try to reuse a Loading component after calling dismiss() on it, it will throw a quite unclear error message.

At first, looking at the docs, I would imagine that the Loading component is reusable and that we only need to call .create() to config the desired look and behavior but It turns out that if the loader is dismissed, you can't use it again. I am not sure if that is a bug or the expected behavior. If it is, I believe something like .dispose() instead of dismiss() would be more clear.

See plunkers below for cases with and without the issue.

What behavior are you expecting?

No error.

Steps to reproduce:

  1. Create a Loader
  2. Call .nav.present(loader) to show it.
  3. Programatically dismiss the loader
  4. Try calling .nav.present(loader) again.
  loading: Loading = Loading.create({
      content: "Please wait..."
    });

  loadData() {
    this.nav.present(this.loading);
    setTimeout(() => {
        this.loading.dismiss();
    }, 1500);
  }

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Attempt to use a dehydrated detector: HostLoadingCmp_0
ORIGINAL STACKTRACE:
Error: Attempt to use a dehydrated detector: HostLoadingCmp_0
    at DehydratedException.BaseException [as constructor] (https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js:7587:21)
    at new DehydratedException (https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js:4944:14)
    at AbstractChangeDetector.throwDehydratedError (https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js:9807:13)
    at AbstractChangeDetector.detectChangesInRecords (https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js:9686:14)
    at AbstractChangeDetector.runDetectChanges (https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js:9672:12)
    at AbstractChangeDetector.detectChanges (https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js:9661:12)
    at ChangeDetectorRef_.detectChanges (https://code.angularjs.org/2.0.0-beta.15/angular2.dev.js:5280:16)
    at Loading.willEnter (https://npmcdn.com/ionic-angular@2.0.0-beta.6/bundles/ionic.system.js:26406:38)
    at Portal._postRender (https://npmcdn.com/ionic-angular@2.0.0-beta.6/bundles/ionic.system.js:24306:46)
    at Portal._render (https://npmcdn.com/ionic-angular@2.0.0-beta.6/bundles/ionic.system.js:24238:34)
ERROR CONTEXT:

Which Ionic Version? 1.x or 2.x
2.x
.beta.6

Plunker that shows an example of your issue

-With the issue:
http://plnkr.co/edit/LY1wi7fh5AxeRNoDzOan?p=preview

-No issue when always re-creating the loader:
http://plnkr.co/edit/PgRxBtAnglTVaxfelq8i?p=preview

Run ionic info from terminal/cmd prompt: (paste output below)

Cordova CLI: 5.4.1
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.6
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
ios-deploy version: 1.8.4
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v4.0.0
Xcode version: Xcode 7.3 Build version 7D175

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions