ModalComponentProp

Interface of the modal prop exposed by the library specifically to modal components.

export type ModalComponentProp<
  P extends ModalfyParams,
  Props = unknown,
  M = keyof P
> = Props & {
  modal: UsableModalComponentProp<P, M>
}

// ------------------ INTERNAL TYPES ------------------ //

type ModalfyParams = { [key: string]: any }

interface UsableModalComponentProp<
  P extends ModalfyParams,
  M extends keyof P
> extends<UsableModalProp<P>> {
  addListener: ModalListener
  getParam: <N extends keyof P[M], D extends P[M][N]>(
    paramName: N,
    defaultValue?: D,
  ) => D extends P[M][N] ? P[M][N] : undefined
  removeAllListeners: () => void
  params?: P[M]
}

type ModalListener = (
  eventName: 'onAnimate',
  callback: (value?: number) => void,
) => ModalEventListener

type ModalEventListener = { remove: () => boolean }
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.

API reference

addListener

Function that allows you to hook a listener to the animatedValue of the modal represented by the component you're in.

Example:

getParam

Function that looks inside params and returns you the value of the key corresponding to paramName. Returns the provided defaultValue if nothing was found.

Example:

removeAllListeners

Removes all the listeners connected to the modal component you're in.

Example:

params

Optional params you provided when opening the modal you're in.

Example:

Last updated

Was this helpful?