diff --git a/src/context/notify.tsx b/src/context/notify.tsx index 7b84c98dc..6b179a3b6 100644 --- a/src/context/notify.tsx +++ b/src/context/notify.tsx @@ -77,12 +77,14 @@ export const NotifyProvider: FC = ({ children }) => { const [notification, setNotification] = useState(null); const { state, pathname } = useLocation() as QueuedNotification; + const clear = () => notification !== null && setNotification(null); + useEffect(() => { if (state?.queuedNotification) { setDeduplicated(state.queuedNotification); window.history.replaceState({}, ""); } else { - notification !== null && setNotification(null); + clear(); } }, [state, pathname]); @@ -95,7 +97,7 @@ export const NotifyProvider: FC = ({ children }) => { const helper: NotificationHelper = { notification, - clear: () => notification !== null && setNotification(null), + clear, queue, failure: (title, error, message, actions) => setDeduplicated(failure(title, error, message, actions)),