UNPKG

@refinedev/core

Version:

Refine is a React meta-framework for building enterprise-level, data-intensive applications rapidly with support for modern UI libraries and headless integrations.

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; };