mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 10:41:13 +08:00
chore(all): sync with main for beta 7
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { ModalOptions, modalController } from '@ionic/core/components';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { HookOverlayOptions } from './HookOverlayOptions';
|
||||
import { ReactComponentOrElement, useOverlay } from './useOverlay';
|
||||
@ -9,7 +10,10 @@ import { ReactComponentOrElement, useOverlay } from './useOverlay';
|
||||
* @param componentProps The props that will be passed to the component, if required
|
||||
* @returns Returns the present and dismiss methods in an array
|
||||
*/
|
||||
export function useIonModal(component: ReactComponentOrElement, componentProps?: any): UseIonModalResult {
|
||||
export function useIonModal(
|
||||
component: ReactComponentOrElement,
|
||||
componentProps?: any
|
||||
): UseIonModalResult {
|
||||
const controller = useOverlay<ModalOptions, HTMLIonModalElement>(
|
||||
'IonModal',
|
||||
modalController,
|
||||
@ -17,14 +21,14 @@ export function useIonModal(component: ReactComponentOrElement, componentProps?:
|
||||
componentProps
|
||||
);
|
||||
|
||||
function present(options: Omit<ModalOptions, 'component' | 'componentProps'> & HookOverlayOptions = {}) {
|
||||
controller.present(options as any);
|
||||
};
|
||||
const present = useCallback(
|
||||
(options: Omit<ModalOptions, 'component' | 'componentProps'> & HookOverlayOptions = {}) => {
|
||||
controller.present(options as any);
|
||||
},
|
||||
[controller.present]
|
||||
);
|
||||
|
||||
return [
|
||||
present,
|
||||
controller.dismiss
|
||||
];
|
||||
return [present, controller.dismiss];
|
||||
}
|
||||
|
||||
export type UseIonModalResult = [
|
||||
|
Reference in New Issue
Block a user