openify
v1.0.0
Published
> 简化 React 弹窗类组件调用的工具
Downloads
6
Readme
Openify
简化 React 弹窗类组件调用的工具
快速上手
安装依赖
npm install openify
# or
yarn add openify
# or
pnpm add openify
开发组件,注意实现visible
, onClose
, afterClose
这三个 props
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>
);
};
使用openify
生成对应的open
函数
const openMyModal = openify(MyModal);
使用open
方法
function MyApp() {
return <Button onClick={() => openMyModal()}>打开弹窗</Button>;
}