rc-mount
v2.1.0
Published
react extra component mount decorator
Downloads
5
Maintainers
Readme
rc-mount
react extra component mount decorator
Install
yarn add rc-mount
# OR
npm i --save rc-mount
Usage
// Modal.tsx
import mount, { ComponentMountProps } from 'rc-mount';
interface IProps {
value: string;
}
const Modal = (props: IProps & ComponentMountProps<string>) => {
const handleClick = () => {
props.resolve(props.value);
setTimeout(() => {
props.destroy();
}, 300);
};
return (
<div>
<p>{props.value}</p>
<button onClick={handleClick}>click</button>
</div>
);
};
export const show = mount()(Modal);
export default Modal;
// index.tsx
import { show as showModal } from './Modal.js';
const res = await showModal();
// OR
const promise = showModal();
promise.destroy();
await promise;
mount(options:Object)=>(WrappedComponent: React.Component)=>React.Component
| option | description | type | default | | --- | --- | --- | --- | | element | render container | string | div |