mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed lab node click handlers with hooks
This commit is contained in:
parent
1db5c64d06
commit
d865067eaf
6 changed files with 26 additions and 18 deletions
10
src/utils/hooks/node/useGotoNode.ts
Normal file
10
src/utils/hooks/node/useGotoNode.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { INode } from '~/redux/types';
|
||||
import { useHistory } from 'react-router';
|
||||
import { useCallback } from 'react';
|
||||
import { URLS } from '~/constants/urls';
|
||||
|
||||
// useGotoNode returns fn, that navigates to node
|
||||
export const useGotoNode = (id: INode['id']) => {
|
||||
const history = useHistory();
|
||||
return useCallback(() => history.push(URLS.NODE_URL(id)), [id]);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue