- Add jscodeshift-based codemod to convert arrow function components to function declarations - Support React.FC, observer-wrapped, and forwardRef components - Include comprehensive test suite covering edge cases - Add npm script to run transformer across codebase - Target only .tsx files in source directories, excluding node_modules and declaration files * [WEB-5459] chore: updates after running codemod --------- Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
import { createContext } from "react";
|
|
// plane admin store
|
|
import { RootStore } from "@/plane-admin/store/root.store";
|
|
|
|
let rootStore = new RootStore();
|
|
|
|
export const StoreContext = createContext(rootStore);
|
|
|
|
function initializeStore(initialData = {}) {
|
|
const singletonRootStore = rootStore ?? new RootStore();
|
|
// If your page has Next.js data fetching methods that use a Mobx store, it will
|
|
// get hydrated here, check `pages/ssg.js` and `pages/ssr.js` for more details
|
|
if (initialData) {
|
|
singletonRootStore.hydrate(initialData);
|
|
}
|
|
// For SSG and SSR always create a new store
|
|
if (typeof window === "undefined") return singletonRootStore;
|
|
// Create the store once in the client
|
|
if (!rootStore) rootStore = singletonRootStore;
|
|
return singletonRootStore;
|
|
}
|
|
|
|
export type StoreProviderProps = {
|
|
children: React.ReactNode;
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
initialState?: any;
|
|
};
|
|
|
|
export function StoreProvider({ children, initialState = {} }: StoreProviderProps) {
|
|
const store = initializeStore(initialState);
|
|
return <StoreContext.Provider value={store}>{children}</StoreContext.Provider>;
|
|
}
|