created template context and type
This commit is contained in:
parent
0b087e28c5
commit
284f865c36
2 changed files with 28 additions and 0 deletions
21
src/frontend/src/contexts/templatesContext.tsx
Normal file
21
src/frontend/src/contexts/templatesContext.tsx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { createContext, ReactNode, useState } from "react";
|
||||
import { Node } from "reactflow";
|
||||
import { TemplateContextType } from "../types/templatesContext";
|
||||
//context to share types adn functions from nodes to flow
|
||||
|
||||
const initialValue: TemplateContextType = {
|
||||
templates: {},
|
||||
setTemplates: () => {},
|
||||
};
|
||||
|
||||
export const TemplatesContext =
|
||||
createContext<TemplateContextType>(initialValue);
|
||||
|
||||
export function TypesProvider({ children }: { children: ReactNode }) {
|
||||
const [templates, setTemplates] = useState({});
|
||||
return (
|
||||
<TemplatesContext.Provider value={{ templates, setTemplates }}>
|
||||
{children}
|
||||
</TemplatesContext.Provider>
|
||||
);
|
||||
}
|
||||
7
src/frontend/src/types/templatesContext/index.ts
Normal file
7
src/frontend/src/types/templatesContext/index.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
const template:{[char: string]: string}={}
|
||||
|
||||
export type TemplateContextType = {
|
||||
templates: typeof template;
|
||||
setTemplates: (newState: {}) => void;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue