mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
docs(loading): show how to use dismiss method returns from useIonLoading for react (#23537)
This commit is contained in:
@ -139,17 +139,23 @@ import { IonButton, IonContent, IonPage, useIonLoading } from '@ionic/react';
|
|||||||
interface LoadingProps {}
|
interface LoadingProps {}
|
||||||
|
|
||||||
const LoadingExample: React.FC<LoadingProps> = () => {
|
const LoadingExample: React.FC<LoadingProps> = () => {
|
||||||
const [present] = useIonLoading();
|
const [present, dismiss] = useIonLoading();
|
||||||
|
/**
|
||||||
|
* The recommended way of dismissing is to use the `dismiss` property
|
||||||
|
* on `IonLoading`, but the `dismiss` method returned from `useIonLoading`
|
||||||
|
* can be used for more complex scenarios.
|
||||||
|
*/
|
||||||
return (
|
return (
|
||||||
<IonPage>
|
<IonPage>
|
||||||
<IonContent>
|
<IonContent>
|
||||||
<IonButton
|
<IonButton
|
||||||
expand="block"
|
expand="block"
|
||||||
onClick={() =>
|
onClick={() => {
|
||||||
present({
|
present({
|
||||||
duration: 3000,
|
message: 'Loading...',
|
||||||
|
duration: 3000
|
||||||
})
|
})
|
||||||
}
|
}}
|
||||||
>
|
>
|
||||||
Show Loading
|
Show Loading
|
||||||
</IonButton>
|
</IonButton>
|
||||||
|
|||||||
@ -7,17 +7,23 @@ import { IonButton, IonContent, IonPage, useIonLoading } from '@ionic/react';
|
|||||||
interface LoadingProps {}
|
interface LoadingProps {}
|
||||||
|
|
||||||
const LoadingExample: React.FC<LoadingProps> = () => {
|
const LoadingExample: React.FC<LoadingProps> = () => {
|
||||||
const [present] = useIonLoading();
|
const [present, dismiss] = useIonLoading();
|
||||||
|
/**
|
||||||
|
* The recommended way of dismissing is to use the `dismiss` property
|
||||||
|
* on `IonLoading`, but the `dismiss` method returned from `useIonLoading`
|
||||||
|
* can be used for more complex scenarios.
|
||||||
|
*/
|
||||||
return (
|
return (
|
||||||
<IonPage>
|
<IonPage>
|
||||||
<IonContent>
|
<IonContent>
|
||||||
<IonButton
|
<IonButton
|
||||||
expand="block"
|
expand="block"
|
||||||
onClick={() =>
|
onClick={() => {
|
||||||
present({
|
present({
|
||||||
duration: 3000,
|
message: 'Loading...',
|
||||||
|
duration: 3000
|
||||||
})
|
})
|
||||||
}
|
}}
|
||||||
>
|
>
|
||||||
Show Loading
|
Show Loading
|
||||||
</IonButton>
|
</IonButton>
|
||||||
|
|||||||
Reference in New Issue
Block a user