1
0
Fork 0
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:
Fedor Katurov 2023-03-16 16:37:43 +06:00
parent 14bf5be65f
commit d9544e917b
13 changed files with 156 additions and 27 deletions

View file

@ -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]);
};