BlueWallet/hooks/useIsLargeScreen.ts

18 lines
607 B
TypeScript
Raw Normal View History

import { useContext } from 'react';
import { LargeScreenContext } from '../components/Context/LargeScreenProvider';
2024-08-25 16:47:44 +02:00
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');
}
2024-08-25 16:47:44 +02:00
return {
isLargeScreen: context.isLargeScreen,
setLargeScreenValue: context.setLargeScreenValue,
};
};