mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
resetting node on unmount
This commit is contained in:
parent
5b507bc736
commit
1db5c64d06
1 changed files with 6 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { nodeGotoNode } from '~/redux/node/actions';
|
import { nodeGotoNode, nodeSetCurrent } from '~/redux/node/actions';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
|
import { EMPTY_NODE } from '~/redux/node/constants';
|
||||||
|
|
||||||
// useLoadNode loads node on id change
|
// useLoadNode loads node on id change
|
||||||
export const useLoadNode = (id: any, isLoading: boolean) => {
|
export const useLoadNode = (id: any, isLoading: boolean) => {
|
||||||
|
@ -9,5 +10,9 @@ export const useLoadNode = (id: any, isLoading: boolean) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isLoading) return;
|
if (isLoading) return;
|
||||||
dispatch(nodeGotoNode(parseInt(id, 10), undefined));
|
dispatch(nodeGotoNode(parseInt(id, 10), undefined));
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
dispatch(nodeSetCurrent(EMPTY_NODE));
|
||||||
|
};
|
||||||
}, [dispatch, id]);
|
}, [dispatch, id]);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue