plane/web/components/gantt-chart/contexts/index.tsx
sriram veeraghanta 3d09a69d58
fix: eslint issues and reconfiguring (#3891)
* fix: eslint fixes

---------

Co-authored-by: gurusainath <gurusainath007@gmail.com>
2024-03-06 18:39:14 +05:30

24 lines
776 B
TypeScript

import React, { FC, createContext } from "react";
// mobx store
import { GanttStore } from "store/issue/issue_gantt_view.store";
let ganttViewStore = new GanttStore();
export const GanttStoreContext = createContext<GanttStore>(ganttViewStore);
const initializeStore = () => {
const newGanttViewStore = ganttViewStore ?? new GanttStore();
if (typeof window === "undefined") return newGanttViewStore;
if (!ganttViewStore) ganttViewStore = newGanttViewStore;
return newGanttViewStore;
};
type GanttStoreProviderProps = {
children: React.ReactNode;
};
export const GanttStoreProvider: FC<GanttStoreProviderProps> = ({ children }) => {
const store = initializeStore();
return <GanttStoreContext.Provider value={store}>{children}</GanttStoreContext.Provider>;
};