UNPKG

@refinedev/core

Version:

refine is a React-based framework for building internal tools, rapidly. It ships with Ant Design System, an enterprise-level UI toolkit.

28 lines (22 loc) 703 B
import { useCallback } from "react"; import { useNotification } from "@hooks"; import type { OpenNotificationParams } from "../../../contexts/notification/types"; export const useHandleNotification = (): typeof handleNotification => { const { open } = useNotification(); const handleNotification = useCallback( ( notification: OpenNotificationParams | false | undefined, fallbackNotification?: OpenNotificationParams, ) => { if (notification !== false) { if (notification) { open?.(notification); } else if (fallbackNotification) { open?.(fallbackNotification); } } }, [], ); return handleNotification; };