Skip to content

Commit 86a9140

Browse files
add tablet small
1 parent 07cf901 commit 86a9140

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/hooks/useScreenWidth.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import { useEffect, useState } from 'react'
22

3-
export const useScreenWidth = (): 'MOBILE' | 'TABLET' | 'DESKTOP' => {
3+
export const useScreenWidth = ():
4+
| 'MOBILE'
5+
| 'TABLET_SMALL'
6+
| 'TABLET'
7+
| 'DESKTOP' => {
48
const [screenWidth, setScreenWidth] = useState<
5-
'MOBILE' | 'TABLET' | 'DESKTOP'
9+
'MOBILE' | 'TABLET_SMALL' | 'TABLET' | 'DESKTOP'
610
>('MOBILE')
711

812
useEffect(() => {
913
const handleScreenWidth = () => {
1014
if (window.innerWidth < 640) {
1115
setScreenWidth('MOBILE')
16+
} else if (window.innerWidth < 768) {
17+
setScreenWidth('TABLET_SMALL')
1218
} else if (window.innerWidth < 1024) {
1319
setScreenWidth('TABLET')
1420
} else setScreenWidth('DESKTOP')

0 commit comments

Comments
 (0)