import type { FC } from 'react' import { createContext, useRef } from 'react' import { createLastRunStore } from './store' type LastRunStoreApi = ReturnType type LastRunContextType = LastRunStoreApi | undefined export const LastRunContext = createContext(undefined) type LastRunProviderProps = { children: React.ReactNode } const LastRunProvider: FC = ({ children, }) => { const storeRef = useRef() if (!storeRef.current) storeRef.current = createLastRunStore() return ( {children} ) } export default LastRunProvider