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

24 lines
460 B
TypeScript
Raw Normal View History

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