feat: add hook useShowToast.ts
All checks were successful
it-academy/dry-wash-pl/pipeline/pr-main This commit looks good
All checks were successful
it-academy/dry-wash-pl/pipeline/pr-main This commit looks good
This commit is contained in:
28
src/hooks/useShowToast.ts
Normal file
28
src/hooks/useShowToast.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useToast } from '@chakra-ui/react';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
const useShowToast = () => {
|
||||
const toast = useToast();
|
||||
|
||||
const showToast = useCallback(
|
||||
(
|
||||
title: string,
|
||||
status: 'info' | 'warning' | 'success' | 'error',
|
||||
description?: string,
|
||||
) => {
|
||||
toast({
|
||||
title,
|
||||
description,
|
||||
status,
|
||||
duration: 5000,
|
||||
isClosable: true,
|
||||
position: 'top-right',
|
||||
});
|
||||
},
|
||||
[toast],
|
||||
);
|
||||
|
||||
return showToast;
|
||||
};
|
||||
|
||||
export default useShowToast;
|
||||
Reference in New Issue
Block a user