File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -31,12 +31,11 @@ export const useViewportEffect = <T>(
31
31
hasRootProviderAsParent,
32
32
} = useContext ( ViewportContext ) ;
33
33
34
- if ( ! hasRootProviderAsParent ) {
35
- warnNoContextAvailable ( 'useViewport' ) ;
36
- return ;
37
- }
38
-
39
34
useEffect ( ( ) => {
35
+ if ( ! hasRootProviderAsParent ) {
36
+ warnNoContextAvailable ( 'useViewport' ) ;
37
+ return ;
38
+ }
40
39
addViewportChangeListener ( handleViewportChange , {
41
40
notifyScroll : ( ) => ! options . disableScrollUpdates ,
42
41
notifyDimensions : ( ) => ! options . disableDimensionsUpdates ,
@@ -45,7 +44,7 @@ export const useViewportEffect = <T>(
45
44
recalculateLayoutBeforeUpdate : options . recalculateLayoutBeforeUpdate ,
46
45
} ) ;
47
46
return ( ) => removeViewportChangeListener ( handleViewportChange ) ;
48
- } , [ addViewportChangeListener , removeViewportChangeListener ] ) ;
47
+ } , [ addViewportChangeListener || null , removeViewportChangeListener || null ] ) ;
49
48
} ;
50
49
51
50
export const useViewport = ( options : IFullOptions = { } ) : IViewport => {
You can’t perform that action at this time.
0 commit comments