diff options
| author | Factiven <[email protected]> | 2023-06-18 00:56:47 +0700 |
|---|---|---|
| committer | Factiven <[email protected]> | 2023-06-18 00:56:47 +0700 |
| commit | 62a3826876e6c37002882c1b5712b3771f805907 (patch) | |
| tree | 233f8dd13f33220502476690702d06aac4b56057 /lib | |
| parent | Fixed Error: Missing "key" prop for element in iterator (diff) | |
| download | moopa-62a3826876e6c37002882c1b5712b3771f805907.tar.xz moopa-62a3826876e6c37002882c1b5712b3771f805907.zip | |
Performance update
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/useNotify.js | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/lib/useNotify.js b/lib/useNotify.js deleted file mode 100644 index e6ba7e6..0000000 --- a/lib/useNotify.js +++ /dev/null @@ -1,41 +0,0 @@ -import { useState, useCallback } from "react"; -import { motion as m, AnimatePresence } from "framer-motion"; - -export const useNotification = () => { - const [showNotification, setShowNotification] = useState(false); - const [notificationMessage, setNotificationMessage] = useState(""); - - const show = useCallback( - (message) => { - setNotificationMessage(message); - setShowNotification(true); - setTimeout(() => { - setShowNotification(false); - }, 5000); - }, - [setNotificationMessage, setShowNotification] - ); - - const NotificationComponent = () => { - return ( - <AnimatePresence> - {showNotification && ( - <m.div - key="teasa" - transition={{ duration: 0.5 }} - initial={{ opacity: 0, y: 100 }} - animate={{ opacity: 1, y: 0 }} - exit={{ opacity: 0, y: 100 }} - className="z-50 fixed bottom-10 w-screen flex justify-center text-center" - > - <div className="bg-green-600 text-white px-2 py-2 font-bold rounded-[30px]"> - {notificationMessage} - </div> - </m.div> - )} - </AnimatePresence> - ); - }; - - return { Notification: NotificationComponent, show }; -}; |