LoadingController: TypeError: Cannot read property 'present' of undefined
See original GitHub issueBug Report
Ionic version:
[x] 4.x
Current behavior:
When attempting to create a new loadingController
, and when attempting to call any method on it, I receive the below error in my browser console:
TypeError: Cannot read property 'present' of undefined
’
I am using Ionic with Capacitor. I’m not sure if the issue should be filed with them or Ionic. I figured I would start here, since the issue is with Ionic’s loadingController
feature.
Expected behavior:
I should not be receiving this error, and this.loading
should be defined.
Steps to reproduce:
- Instantiate a new
loadingController
withawait this.$ionic.loadingController.create()
- Attempt to call any method on it
- Receive an error that the newly created
loadingController
is undefined
Related code:
async presentLoading() {
this.loading = await this.$ionic.loadingController.create();
return await this.loading.present();
},
Other information:
Same issues as:
- https://github.com/ionic-team/ionic/issues/14800
- https://stackoverflow.com/questions/54053245/ionic-4-loading-present-is-not-a-function
Ionic info:
Ionic:
ionic (Ionic CLI) : 4.5.0 (/usr/local/lib/node_modules/ionic)
System:
NodeJS : v9.11.1 (/usr/local/bin/node)
npm : 6.5.0
OS : macOS Mojave
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
LoadingController: TypeError: Cannot read property 'present ...
Receive an error that the newly created loadingController is undefined. Related code: async presentLoading() { this.loading = await this.$ionic.
Read more >TypeError: Cannot read property 'dismiss' of undefined in ionic ...
Create a hideLoading() method like below can call it when you want to hide the loading circle. async hideLoading() { this.loadingController.
Read more >LoadingController not injected in the component and remains ...
ERROR TypeError: Cannot read properties of undefined (reading 'create') at SafeSubscriber.showLoading [as _next] (login.page.ts:61).
Read more >[Solved]-How to fix cannot read property 'dismiss' of undefined ...
The easiest fix is to turn this into any, there is no such Element name HTMLIonLoadingElement - or if its an interface you...
Read more >Using LoadingController in Ionic 4 — waiting for API response
In the “Case 1”, we are calling present() method on our instance of loading controller which is returning Promise and when it shows...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So, I’ve found a workaround for my issue trying to create a loading inside the vue’s mounted hook. I’ve simple added a setTimeout and created inside of it… As I was hoping that the problem was that the ionic hasn’t yet “kicked” in, and created the ion-loading-controller, so I’ve created a timeout to push the loading creation in the call stack, and well… it worked.
Before:
After:
Thanks for the issue! This issue is being closed due to the lack of a reply. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Thank you for using Ionic!