mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 18:17:31 +08:00
refactor(modal): use framework delegate for mounting the user's component
This commit is contained in:
13
packages/react/src/apis/modal.ts
Normal file
13
packages/react/src/apis/modal.ts
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
import { ModalOptions } from '@ionic/core';
|
||||
|
||||
import { Delegate } from '../react-framework-delegate';
|
||||
import { getOrAppendElement } from '../utils/helpers';
|
||||
|
||||
export function createModal(opts: ModalOptions): Promise<HTMLIonModalElement> {
|
||||
opts.delegate = Delegate;
|
||||
const element = getOrAppendElement('ion-modal-controller') as HTMLIonModalControllerElement;
|
||||
return (element as any).componentOnReady().then(() => {
|
||||
return element.create(opts);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user