16 lines
440 B
TypeScript
16 lines
440 B
TypeScript
import { modals } from "@mantine/modals";
|
|
import { useCallback } from "react";
|
|
|
|
export default function useModal<T>(
|
|
Component: React.ComponentType<T>,
|
|
title: string
|
|
) {
|
|
const openModal = useCallback((params: T) => {
|
|
modals.open({
|
|
title,
|
|
children: <Component afterSubmit={() => modals.closeAll()} {...params} />,
|
|
});
|
|
}, [Component, title]);
|
|
|
|
return openModal;
|
|
} |