modalfy

circle-info

Function that exposes Modalfy's API outside of React's context.

triangle-exclamation
circle-check
const modalfy = <
  P extends ModalfyParamsm,
  M extends keyof P
>(): UsableModalProp<P> => {
  const context: UsableModalProp<P> = React.useContext(ModalContext)
  return {
    closeAllModals: ModalState.closeAllModals,

    closeModal: () => ModalState.closeModal(),

    closeModals: (modalName: M) => ModalState.closeModals(modalName),

    currentModal: ModalState.getState<P>()?.currentModal,

    openModal: (modalName: M, params?: P[M]) =>
      ModalState.openModal(modalName, params, true),
  }
}
Unexpected error with integration github-files: Integration is not authenticated with GitHub
Types have been simplified for the sake of clarity. Refer to the exact definitions here.
circle-info

If you're using TypeScript and have your params types, you can get some nice autocomplete by utilising modalfy()like this:

Last updated