const App: React.FC = () => {
const { status, data, error } = useGetSession();
if (error) {
return <span>Error loading session {error.message}</span>
}
else if (status === 'loading') {
return <IonLoading isopen={true}/>
}
if (status === "success") {
<IonApp></IonApp>
}
}
In react strict mode, this code will always display the loading component and it will never go away because strict mode re-renders your component twice.
The reason is that the way works, if you call it twice, it won’t disappear if you call it with <IonLoading isOpen={false}). The same applies with useIonLoading and present() and dismiss(); IonLoading kind of works like a modal dialog and so this won’t work with react strict mode.
Note: If I use a component that doesn’t present as a modal like this is no problem.
Any suggestions on how to make this work with IonModal?
Note: I’m using tanstack query for my data loading.
My ionic info:
Ionic:
Ionic CLI : 7.1.1 (/Users/rpatulski/.nvm/versions/node/v18.12.1/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 7.4.3
Capacitor:
Capacitor CLI : 5.4.2
@capacitor/android : not installed
@capacitor/core : 5.4.2
@capacitor/ios : not installed
Utility:
cordova-res : not installed globally
native-run : 1.7.3
System:
NodeJS : v18.12.1 (/Users/rpatulski/.nvm/versions/node/v18.12.1/bin/node)
npm : 8.19.2
OS : macOS Monterey
Thanks