mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-13 09:01:54 +00:00
15 lines
426 B
TypeScript
15 lines
426 B
TypeScript
import { useCallback, useState } from "react";
|
|
|
|
export function useToast(duration = 3000) {
|
|
const [toast, setToast] = useState<{ message: string; type: "success" | "error" } | null>(null);
|
|
|
|
const showToast = useCallback(
|
|
(message: string, type: "success" | "error") => {
|
|
setToast({ message, type });
|
|
setTimeout(() => setToast(null), duration);
|
|
},
|
|
[duration],
|
|
);
|
|
|
|
return { toast, showToast };
|
|
}
|