ngx-scanner icon indicating copy to clipboard operation
ngx-scanner copied to clipboard

ExpressionChangedAfterItHasBeenCheckedError

Open gabrielbusarello opened this issue 5 years ago • 2 comments

Describe the bug When switching between cameras throws the error: ExpressionChangedAfterItHasBeenCheckedError. The error throws in the stackblitz example of yours too.

In that link: https://zxing-js.github.io/ngx-scanner/

To Reproduce Steps to reproduce the behavior:

  1. Open the console
  2. Select some other devices
  3. See error.

Expected behavior A clear and concise description of what you expected to happen. Change device without throws errors.

Screenshots If applicable, add screenshots to help explain your problem. image

Desktop (please complete the following information):

  • OS: [e.g. iOS]: Windows 10 PRO
  • Browser [e.g. chrome, safari]: Chrome.
  • Version [e.g. 22]: 79.0.3945.79

gabrielbusarello avatar Dec 17 '19 19:12 gabrielbusarello

I removed that warning by adding a setTimeout to the reset method:

/**
     * Resets the scanner and emits device change.
     */
    ZXingScannerComponent.prototype.reset = function () {
        this._reset();
        setTimeout(() => {
            this.deviceChange.emit(null);
        })
    };

rafaellyra avatar Feb 18 '20 10:02 rafaellyra

ZXingScannerComponent.prototype.reset = function () { this._reset(); setTimeout(() => { this.deviceChange.emit(null); }) };

@rafaellyra, where do you put this code to get rid of that error?

krumholz avatar Jul 10 '20 21:07 krumholz