diff --git a/src/utils/hooks/node/useLoadNode.ts b/src/utils/hooks/node/useLoadNode.ts index 6d21392a..600fa0a2 100644 --- a/src/utils/hooks/node/useLoadNode.ts +++ b/src/utils/hooks/node/useLoadNode.ts @@ -1,6 +1,7 @@ import { useEffect } from 'react'; -import { nodeGotoNode } from '~/redux/node/actions'; +import { nodeGotoNode, nodeSetCurrent } from '~/redux/node/actions'; import { useDispatch } from 'react-redux'; +import { EMPTY_NODE } from '~/redux/node/constants'; // useLoadNode loads node on id change export const useLoadNode = (id: any, isLoading: boolean) => { @@ -9,5 +10,9 @@ export const useLoadNode = (id: any, isLoading: boolean) => { useEffect(() => { if (isLoading) return; dispatch(nodeGotoNode(parseInt(id, 10), undefined)); + + return () => { + dispatch(nodeSetCurrent(EMPTY_NODE)); + }; }, [dispatch, id]); };