We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 07cf901 commit 86a9140Copy full SHA for 86a9140
src/hooks/useScreenWidth.ts
@@ -1,14 +1,20 @@
1
import { useEffect, useState } from 'react'
2
3
-export const useScreenWidth = (): 'MOBILE' | 'TABLET' | 'DESKTOP' => {
+export const useScreenWidth = ():
4
+ | 'MOBILE'
5
+ | 'TABLET_SMALL'
6
+ | 'TABLET'
7
+ | 'DESKTOP' => {
8
const [screenWidth, setScreenWidth] = useState<
- 'MOBILE' | 'TABLET' | 'DESKTOP'
9
+ 'MOBILE' | 'TABLET_SMALL' | 'TABLET' | 'DESKTOP'
10
>('MOBILE')
11
12
useEffect(() => {
13
const handleScreenWidth = () => {
14
if (window.innerWidth < 640) {
15
setScreenWidth('MOBILE')
16
+ } else if (window.innerWidth < 768) {
17
+ setScreenWidth('TABLET_SMALL')
18
} else if (window.innerWidth < 1024) {
19
setScreenWidth('TABLET')
20
} else setScreenWidth('DESKTOP')
0 commit comments