mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +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 { 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]);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue