UNPKG

@datalayer/core

Version:
27 lines (26 loc) 848 B
import { jsx as _jsx } from "react/jsx-runtime"; /* * Copyright (c) 2023-2025 Datalayer, Inc. * Distributed under the terms of the Modified BSD License. */ import { useState } from "react"; import { Flash } from '@primer/react'; export const ErrorMessage = ({ message }) => { if (message instanceof Array) { return _jsx("div", { children: message.map((m, i) => _jsx(Flash, { variant: "danger", children: m }, i)) }); } else { return _jsx(Flash, { variant: "danger", children: message }); } }; export const useError = (initialState) => { const [error, setError] = useState(initialState); const showError = (errorMessage) => { setError(errorMessage); window.setTimeout(() => { setError(null); }, 3000); }; return { error, showError }; }; export default useError;