1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

add backlinks

This commit is contained in:
Fedor Katurov 2023-06-11 20:16:55 +06:00
parent 6222b75563
commit 811e7740a9
21 changed files with 257 additions and 56 deletions

View file

@ -1,22 +1,29 @@
import React, { createContext, FC, useContext } from 'react';
import { EMPTY_NODE } from '~/constants/node';
import { INode } from '~/types';
import { INode, NodeBackLink } from '~/types';
export interface NodeContextProps {
node: INode;
backlinks?: NodeBackLink[];
update: (node: Partial<INode>) => Promise<unknown>;
isLoading: boolean;
}
export const NodeContext = createContext<NodeContextProps>({
node: EMPTY_NODE,
backlinks: [] as NodeBackLink[] | undefined,
update: async () => {},
isLoading: false,
});
export const NodeContextProvider: FC<NodeContextProps> = ({ children, ...contextValue }) => {
return <NodeContext.Provider value={contextValue}>{children}</NodeContext.Provider>;
export const NodeContextProvider: FC<NodeContextProps> = ({
children,
...contextValue
}) => {
return (
<NodeContext.Provider value={contextValue}>{children}</NodeContext.Provider>
);
};
export const useNodeContext = () => useContext(NodeContext);