withModal
Note: Prefer useModal() Hooks if you're using a functional component.
The modal prop injected bywithodal()is covered in ModalProp.
const withModal = <P extends ModalfyParams, Props extends object>(
Component: React.ComponentClass<Props>,
) => {
class WithModalComponent extends React.Component<ModalProp<P, Props>> {
render() {
return (
<ModalContext.Consumer>
{(context) => (
<Component
modal={{
closeAllModals: context.closeAllModals,
currentModal: context.currentModal,
closeModals: context.closeModals,
closeModal: context.closeModal,
openModal: context.openModal,
}}
/>
)}
</ModalContext.Consumer>
)
}
}
return WithModalComponent
}Unexpected error with integration github-files: Integration is not authenticated with GitHub
API reference
Using withModal will give you access to:
this.props.modalcurrentModal: name of the current displayed modal if there's oneopenModal: open a specific modalcloseModal: close a modalcloseModals: close every instance of a given modalcloseAllModals: close all open modals
as seen in ModalProp.
Last updated
Was this helpful?