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

RangeError: Maximum call stack size exceeded

Open minicatsCB opened this issue 5 years ago • 2 comments

Angular version: 5.2.9

ngx-pagination version: 4.0.0

Description of issue: I have an Ionic with Angular application. I created a custom component which receives two input params currentStep and totalItems. As you can see in the attached Stackblitz, we start in the HomeComponent page. If we click the "ClickMe" button, we go to the InstructionsPage, which makes use of the custom pagination template. The thing is that, if I press the "Go back" button, I return to HomeComponent but, if I press the "ClickMe" button again, an error is thrown.

test

Demo: https://stackblitz.com/edit/ionic-5s2qwc

Sorry, I know there are other similar issues in this repo, but none of then have worked for me or I haven't been able to catch the error in my code.

minicatsCB avatar Jul 15 '19 13:07 minicatsCB

This happens when you subscribe to pagination changes and emit a new event in the same response. That makes a infinite loop

snakone avatar Aug 19 '19 12:08 snakone

I am not familiar with Ionic or how it interacts with Angular, but by putting a few console.log calls in your demo, it seems that the ngOnDestroy method of InstructionsComponent is not called when navigating away with the "go back" button. However, the constructor is called each time "click me" is clicked, which means you are setting up multiple setInterval callbacks that run simultaneously.

This is likely to be the cause of the error. I would advise that you consult the Ionic documentation to see the correct place to put clean-up logic so it will run when navigating away from a component. Perhaps they have their own Ionic-specific lifecycle hooks?

michaelbromley avatar Aug 20 '19 08:08 michaelbromley