/* eslint-disable @typescript-eslint/no-explicit-any */ import { createContext, FC, memo, useContext } from "react"; const contextFactory = ( useContextState: (...args: any) => T, ContextComponent?: React.JSX.Element ): { Context: React.Context; Provider: React.MemoExoticComponent>; useContext: () => T; } => { const Context = createContext(Object.create(null) as T); return { Context, Provider: memo(({ children, ...props }: any) => ( {children} {ContextComponent} )) as React.MemoExoticComponent, useContext: () => useContext(Context), }; }; export default contextFactory;