diff --git a/twenty-frontend/src/js/Context.ts b/twenty-frontend/src/js/Context.ts new file mode 100644 index 0000000..c8c3354 --- /dev/null +++ b/twenty-frontend/src/js/Context.ts @@ -0,0 +1,2 @@ +import { createContext } from "react"; +export const ParamContext = createContext>({}); diff --git a/twenty-frontend/src/js/components/App.tsx b/twenty-frontend/src/js/components/App.tsx index 64f606b..db38870 100644 --- a/twenty-frontend/src/js/components/App.tsx +++ b/twenty-frontend/src/js/components/App.tsx @@ -1,14 +1,21 @@ import React, { PropsWithChildren } from "react"; import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client"; +import { ParamContext } from "/Context"; -export function App({children}: PropsWithChildren<{}>) { +export function App({ children }: PropsWithChildren<{}>) { const client = new ApolloClient({ uri: "/graphql", cache: new InMemoryCache(), }); + const params = Object.fromEntries( + location.hash + .substring(1, location.hash.length) + .split(",") + .map(e => e.split("=")), + ); return ( - - {children} - - ) + + {children} + + ); } diff --git a/twenty-frontend/src/js/components/Task.tsx b/twenty-frontend/src/js/components/Task.tsx index ba88c41..e76b394 100644 --- a/twenty-frontend/src/js/components/Task.tsx +++ b/twenty-frontend/src/js/components/Task.tsx @@ -9,8 +9,6 @@ import { rendermd } from "/lib/markdown-utils"; import { NavBar } from "/components/NavBar"; import { Tabs, Tab } from "/components/Tabs"; -import classnames from "classnames"; - const DEFAULT_TASK_CONTENT = [ "## Subtasks", "", diff --git a/twenty-frontend/src/js/main/task/edit.tsx b/twenty-frontend/src/js/main/task/edit.tsx index 4a2b614..f5b6a88 100644 --- a/twenty-frontend/src/js/main/task/edit.tsx +++ b/twenty-frontend/src/js/main/task/edit.tsx @@ -1,16 +1,12 @@ -import React from "react"; +import React, { useContext } from "react"; +import { ParamContext } from "/Context"; import ReactDOM from "react-dom/client"; import { App } from "/components/App"; import { Task } from "/components/Task"; (function () { - const params = Object.fromEntries( - location.hash - .substring(1, location.hash.length) - .split(",") - .map(e => e.split("=")), - ); const root = document.querySelector(".react-root")!; + const params = useContext(ParamContext); ReactDOM.createRoot(root).render(