Ionic React: How to dismiss ion-loading correctly?

I’m a newbie and having some issues with dismissing ion-loading when using the React hook on Ionic React v5.6.11.

I’ve tried the following ways so far:

const [present, dismiss] = useIonLoading();

// does NOT dismiss
const plain = () => {

// does NOT dismiss
const withAwait = async () => {
await present();
await dismiss();

// DOES dismiss if timeout is 50 ms or more but not all the time
const withTimeout = () => {
setTimeout(() => dismiss(), 50);
Please find an example project here

Any advice is much appreciated.

I wouldn’t call present() and dismiss() immediately after each other. You need to run some code in between, or call them separately.

You also might find the example Using with IonLoading component helpful.