While working on my web app, specifically file uploads, Chrome displayed a warning after I called an alert:
Invoking 'alert()' during microtask execution is deprecated and will be removed in M53, around September 2016. See https://www.chromestatus.com/features/5647113010544640 for more details.
However I think that in my situation the call is justified and am a little worried my code won't work once M53 is released. Note that I'm not shipping to production with the alerts, but for testing it is quite valuable.
The situation:
I am developing my app in typescript using react. I'm using axios to do http requests. Basically the http-post looks like this:
axios.post("/upload/", data)
.then((response: any) => {
callback(undefined);
})
.catch((error: any) => {
callback(error);
});
Then in the calling method I'm popping an alert if there's an error so I can be sure the tester/developer will be notified. Kinda like this:
this.service.uploadFile((error: any) => {
if (error) {
console.log(error);
alert("An error occured");
return;
}
this.onUploadCompleted()
});
This is when chrome displays the warning.
First of all I'm wondering if the warning is justified, because the alert is shown until after the request is done and an error was returned. So I'm pretty sure it's not blocking anything.
If it is justified, what can be done so I can display the alert anyway?