BlueWallet/hooks/useIsLargeScreen.ts
2024-08-25 10:47:44 -04:00

18 lines
607 B
TypeScript

import { useContext } from 'react';
import { LargeScreenContext } from '../components/Context/LargeScreenProvider';
interface UseIsLargeScreenResult {
isLargeScreen: boolean;
setLargeScreenValue: (value: 'Handheld' | 'LargeScreen' | undefined) => void;
}
export const useIsLargeScreen = (): UseIsLargeScreenResult => {
const context = useContext(LargeScreenContext);
if (context === undefined) {
throw new Error('useIsLargeScreen must be used within a LargeScreenProvider');
}
return {
isLargeScreen: context.isLargeScreen,
setLargeScreenValue: context.setLargeScreenValue,
};
};