Hello!
I upgraded to ionic version 6 and at coding level everything went very well. Reaching the end of the update of my application, I generated a production version and when accessing the application on my node server , I ran into this error right on the login screen:
For the sake of detail, the error occurred when trying to call the following code:
Generic Alert Statement
const loader = (
mensagem = "Aguarde...",
tipo = "bubbles",
css = "",
id = "loader"
) =>
loadingController.create({
id: id || "loader",
spinner: tipo,
message: mensagem,
translucent: true,
cssClass: css,
backdropDismiss: false
});
Calling this controller at a certain point in the application:
const loading = await loader((reconectar ? 'Validando sessão...' : 'Aguarde...'));
loading.present(); <---error occurs here...
I don’t understand if there was any failure when performing the production build that would have resulted in this problem, as nothing is reported and it is still reported:
Uncaught (in promise) TypeError: (intermediate value)(intermediate value).present is not a function
Help please!
this is how I use it
async genericLoader() {
this.loading = await this.loadingCtrl.create({
spinner: 'bubbles',
duration: 5000,
message: "reading data...',
translucent: true,
});
return await this.loading.present();
}
Thanks,
In case I’m using React. And I import the Loading like this:
import {
loadingController,
toastController,
alertController
} from "@ionic/core";
This statement that you posted loadingCtrl does not for use cases with Angular or am I wrong?
Yes its angular, butni think you can use the example in the ionic docs
I am also getting this. I added a comment with a example project to this issue where someone reported it with the toastController
.
opened 06:29AM - 02 Jan 22 UTC
ionitron: needs reproduction
### Prerequisites
- [X] I have read the [Contributing Guidelines](https://git… hub.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already report this problem, without success.
### Ionic Framework Version
- [ ] v4.x
- [ ] v5.x
- [X] v6.x
### Current Behavior
An error will be reported when toast is created in an external ts file:
```
Uncaught TypeError: Cannot set properties of undefined (setting '$lazyInstance$')
at registerInstance (index-06cd27b1.js?cd96:4)
at new t (overlays-5f2f4ffc.js?9cdf:4)
at eval (overlays-5f2f4ffc.js?9cdf:4)
at async toast (toast.ts?e2e3:4)
registerInstance @ index-06cd27b1.js?cd96:4
t @ overlays-5f2f4ffc.js?9cdf:4
eval @ overlays-5f2f4ffc.js?9cdf:4
Promise.then (async)
createOverlay @ overlays-5f2f4ffc.js?9cdf:4
create @ overlays-5f2f4ffc.js?9cdf:4
toast @ toast.ts?e2e3:4
exeHandler @ index.vue?d776:71
exeHandler @ index.vue?b665:33
eval @ runtime-dom.esm-bundler.js?2725:371
callWithErrorHandling @ runtime-core.esm-bundler.js?d2dd:6737
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js?d2dd:6746
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js?d2dd:6756
invoker @ runtime-dom.esm-bundler.js?2725:357
toast.ts?e2e3:11 Uncaught (in promise) TypeError: t.present is not a function
at toast (toast.ts?e2e3:11)
```
### Expected Behavior
It can run normally like ionic 5.x
### Steps to Reproduce
src/toast.ts
```ts
async function toast(){
const t = await toastController.create({
message: 'hello'
});
t.present();
}
```
src/*.vue
```ts
import toast from './toast';
defineComponent({
setup(){
onMounted(()=>{
toast(); // Uncaught TypeError: Cannot set properties of undefined (setting '$lazyInstance$')
});
}
})
```
### Code Reproduction URL
_No response_
### Ionic Info
Ionic:
Ionic CLI : 6.18.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/vue 6.0.1
Capacitor:
Capacitor CLI : 3.3.3
@capacitor/android : not installed
@capacitor/core : 3.3.3
@capacitor/ios : not installed
Utility:
cordova-res : 0.15.4
native-run : 1.5.0
System:
NodeJS : v14.15.0 (/usr/local/bin/node)
npm : 6.14.8
OS : macOS Monterey
### Additional Information
_No response_
Great guy. I will follow !
In your case this problem occurs at development time or after the ionic build (in production)??
In my case, in development I have no problems. But after the ionic build is the one who gives the error.
Ok, I just figured it out. We need to import from @ionic/vue
and not @ionic/core
. I guess in your case try @ionic/react
/ @ionic/angular
.
It is happening for me in dev - ionic serve
.
Excellent.
If possible, test if after ionic build , the error continues to occur in production and report it here. In my case the error still persists.
Ps: The production environment I’m talking about is not an ionic serve -s build but access the /build folder and start server via Node + Express for example.
thanks!
Works with a prod build too. Ran ionic build
and through it on my local nginx server.
well,
I did my tests and really on Vue everything seems to work perfectly. I created a blank project and implemented my functions and everything happens normally both in dev and in production. In react, I did the same and the error only occurs in production.
Apparently it’s an implementation bug in @ionic /core.
I believe if you test the reverse, creating a blank app in react and running it will get the same result as mine.
Anyway, thank you!
Okay, I just found out. In the case of react we need to import from @ionic /core/components and not from @ionic /core.
I was already worried about this as it was preventing the app from launching into production. But now everything is fine apparently.