import { createContext, useContext } from 'react';
import { rootStore, type RootStoreType } from '../stores/root.tsx';
import * as React from 'react';

const StoreContext = createContext<RootStoreType>(rootStore);

// eslint-disable-next-line react-refresh/only-export-components
export const useRootStore = () => useContext(StoreContext);

export const StoreProvider: React.FC<React.PropsWithChildren> = ({ children }) => {
  return <StoreContext.Provider value={rootStore}>{children}</StoreContext.Provider>;
};
