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>
);
}