Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] useDevice hook 확장 #391

Merged
merged 4 commits into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/common/hooks/useDevice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react';
import { useMediaQuery } from 'react-responsive';

export function useIsTablet(minWidth = '429px', maxWidth = '768px') {
export function useIsTablet(minWidth = '431px', maxWidth = '768px') {
const [isTablet, setIsTablet] = useState(false);
const tablet = useMediaQuery({
query: `(min-width: ${minWidth}) and (max-width: ${maxWidth})`,
Expand All @@ -12,7 +12,7 @@ export function useIsTablet(minWidth = '429px', maxWidth = '768px') {
return isTablet;
}

export function useIsMobile(maxWidth = '428.999px') {
export function useIsMobile(maxWidth = '431px') {
const [isMobile, setIsMobile] = useState(false);
const mobile = useMediaQuery({
query: `(max-width:${maxWidth})`,
Expand All @@ -23,9 +23,9 @@ export function useIsMobile(maxWidth = '428.999px') {
return isMobile;
}

export function useDevice(): 'TAB' | 'MOB' | 'DESK' {
const isTablet = useIsTablet();
const isMobile = useIsMobile();
export function useDevice({ mobMax, tabMax }: { mobMax?: string; tabMax?: string }): 'TAB' | 'MOB' | 'DESK' {
const isTablet = useIsTablet(mobMax, tabMax);
const isMobile = useIsMobile(mobMax);

return isTablet ? 'TAB' : isMobile ? 'MOB' : 'DESK';
}