mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
notifications: for nodes
This commit is contained in:
parent
14bf5be65f
commit
d9544e917b
13 changed files with 156 additions and 27 deletions
|
@ -2,10 +2,15 @@ import { useCallback } from 'react';
|
|||
|
||||
import { URLS } from '~/constants/urls';
|
||||
import { useNavigation } from '~/hooks/navigation/useNavigation';
|
||||
import { INode } from '~/types';
|
||||
|
||||
// useGotoNode returns fn, that navigates to node
|
||||
export const useGotoNode = (id: INode['id']) => {
|
||||
export const useGotoNode = (id?: number) => {
|
||||
const { push } = useNavigation();
|
||||
return useCallback(() => push(URLS.NODE_URL(id)), [push, id]);
|
||||
return useCallback(() => {
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
push(URLS.NODE_URL(id));
|
||||
}, [push, id]);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue