简化 React 弹窗类组件调用的工具
npm install openify
# or
yarn add openify
# or
pnpm add openify
type MyModalProps = OpenableProps<xxx> & {
/** your props **/
};
const MyModal = ({ visible, onClose, afterClose, ...props }: MyModalProps) => {
// your code here
return (
<Modal
visible={visible}
onOk={onClose}
onCancel={onClose}
afterClose={afterClose}
// your other props
>
{/** your content here **/}
</Modal>
);
};
const openMyModal = openify(MyModal);
function MyApp() {
return <Button onClick={() => openMyModal()}>打开弹窗</Button>;
}