Files
full-stack-fastapi-template/frontend/src/hooks/useCustomToast.ts

24 lines
460 B
TypeScript
Raw Normal View History

2024-03-17 17:28:45 +01:00
import { useToast } from "@chakra-ui/react"
import { useCallback } from "react"
const useCustomToast = () => {
2024-03-08 14:58:36 +01:00
const toast = useToast()
2024-03-08 14:58:36 +01:00
const showToast = useCallback(
2024-03-17 17:28:45 +01:00
(title: string, description: string, status: "success" | "error") => {
2024-03-08 14:58:36 +01:00
toast({
title,
description,
status,
isClosable: true,
2024-03-17 17:28:45 +01:00
position: "bottom-right",
2024-03-08 14:58:36 +01:00
})
},
[toast],
)
2024-03-08 14:58:36 +01:00
return showToast
}
2024-03-08 14:58:36 +01:00
export default useCustomToast