/**
* The `useModal` hook provides an easy way to manage the opening and closing of a modal component.
* It uses internal state to track whether the modal is open or closed, and returns a `Modal` component that can be rendered in the UI.
* The hook provides `openModal` and `closeModal` functions for controlling the modal's visibility, and can also handle an optional `onClose` callback when the modal is closed.
*
* @returns An object containing the `Modal` component and functions to open and close it:
* - `openModal`: Opens the modal by setting its state to `true`.
* - `closeModal`: Closes the modal and optionally invokes a callback function.
* - `Modal`: A memoized modal component created by `modalFactory`.
*
* @example
* ```tsx
* const { Modal, openModal, closeModal } = useModal();
*
* return (
* <>
*
*
*