2.0.3 • Published 5 months ago

rc-mount v2.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 months ago

rc-mount

react extra component mount decorator

NPM version gemnasium deps node version npm download

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

optiondescriptiontypedefault
elementrender containerstringdiv
2.0.3

5 months ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.3

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.1

6 years ago