UNPKG

@light-sheet/react

Version:

FortuneSheet is a drop-in javascript spreadsheet library that provides rich features like Excel and Google Sheets

22 lines 880 B
import React, { useContext, useCallback } from "react"; import MessageBox from "../components/MessageBox"; import { ModalContext } from "../context/modal"; export function useAlert() { var _useContext = useContext(ModalContext), showModal = _useContext.showModal, hideModal = _useContext.hideModal; var showAlert = useCallback(function (message) { var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ok"; var onOk = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : hideModal; var onCancel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : hideModal; showModal( /*#__PURE__*/React.createElement(MessageBox, { type: type, onOk: onOk, onCancel: onCancel }, message)); }, [hideModal, showModal]); return { showAlert: showAlert, hideAlert: hideModal }; }