File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -4,22 +4,32 @@ import { useMediaQuery } from './useMediaQuery';
4
4
import { BreakpointMinWidth , BreakpointMaxWidth } from '../enums' ;
5
5
import type { BreakpointToken } from '../types' ;
6
6
7
- export function useBreakpoint ( breakpoint : number | BreakpointToken ) : boolean {
7
+ export function useBreakpoint (
8
+ breakpoint : number | BreakpointToken ,
9
+ defaultValue ?: boolean ,
10
+ ) : boolean {
8
11
switch ( typeof breakpoint ) {
9
12
case 'number' :
10
- return useMediaQuery ( `(min-width: ${ breakpoint } px)` ) ;
13
+ return useMediaQuery ( `(min-width: ${ breakpoint } px)` , defaultValue ) ;
11
14
default :
12
- return useMediaQuery ( `(min-width: ${ BreakpointMinWidth [ breakpoint ] } px)` ) ;
15
+ return useMediaQuery (
16
+ `(min-width: ${ BreakpointMinWidth [ breakpoint ] } px)` ,
17
+ defaultValue ,
18
+ ) ;
13
19
}
14
20
}
15
21
16
22
export function useBreakpointMax (
17
23
breakpoint : number | BreakpointToken ,
24
+ defaultValue ?: boolean ,
18
25
) : boolean {
19
26
switch ( typeof breakpoint ) {
20
27
case 'number' :
21
- return useMediaQuery ( `(max-width: ${ breakpoint } px)` ) ;
28
+ return useMediaQuery ( `(max-width: ${ breakpoint } px)` , defaultValue ) ;
22
29
default :
23
- return useMediaQuery ( `(max-width: ${ BreakpointMaxWidth [ breakpoint ] } px)` ) ;
30
+ return useMediaQuery (
31
+ `(max-width: ${ BreakpointMaxWidth [ breakpoint ] } px)` ,
32
+ defaultValue ,
33
+ ) ;
24
34
}
25
35
}
You can’t perform that action at this time.
0 commit comments