added cashu context to prevent repeated invocation

This commit is contained in:
lemonknowsall committed 2025-10-06 20:47:01 -07:00
1 parent 669a911d59
commit 565305a592
3 files changed
+110 -8

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import { createContext, useContext, ReactNode } from 'react';
import { useCashu as useCashuHook, type UseCashuReturn } from '@/hooks/useCashu';
const CashuContext = createContext<UseCashuReturn | null>(null);
export function CashuProvider({ children }: { children: ReactNode }) {
const cashu = useCashuHook();
return (
<CashuContext.Provider value={cashu}>
{children}
</CashuContext.Provider>
);
}
export function useCashu(): UseCashuReturn {
const context = useContext(CashuContext);
if (!context) {
throw new Error('useCashu must be used within a CashuProvider');
}
return context;
}