created template context and type

This commit is contained in:
anovazzi1 2023-04-19 22:54:46 -03:00
commit 284f865c36
2 changed files with 28 additions and 0 deletions

View 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>
);
}

View file

@ -0,0 +1,7 @@
const template:{[char: string]: string}={}
export type TemplateContextType = {
templates: typeof template;
setTemplates: (newState: {}) => void;
};