Skip to content

v3.1.0

Latest
Compare
Choose a tag to compare
@cheton cheton released this 13 Dec 10:59
· 1 commit to master since this release
5737405

This release provides React Context and Hook API support.

Context API

<ModalProvider>
    <ModalRoot />
    <ModalConsumer>
        {({ openModal, closeModal }) => {
            const handleClick = (e) => openModal(MyModal);
            return (
                <Button onClick={handleClick}>
                    Open Modal
                </Button>
            );
        }}
    </ModalConsumer>
</ModalProvider>

Hook API

const Example = (props) => {
    const { openModal, closeModal } = useModal();
    const handleClick = (e) => openModal(MyModal);

    return (
        <Button onClick={handleClick}>
            {props.children}
        </Button>
    );
}