快速上手

安装依赖

npm
yarn
pnpm
bun
1npm install openify

开发组件,注意实现visibleonCloseafterClose这三个 props

1type MyModalProps = OpenableProps<xxx> & {
2  /** your props **/
3};
4
5const MyModal = ({ visible, onClose, afterClose, ...props }: MyModalProps) => {
6  // your code here
7  return (
8    <Modal
9      visible={visible}
10      onOk={onClose}
11      onCancel={onClose}
12      afterClose={afterClose}
13      // your other props
14    >
15      {/** your content here **/}
16    </Modal>
17  );
18};

使用openify生成对应的open函数

1const openMyModal = openify(MyModal);

使用open方法

1function MyApp() {
2  return <Button onClick={() => openMyModal()}>打开弹窗</Button>;
3}

更多参考API