@@ -34,30 +34,26 @@ const DEFAULT_PROPS = {
34
34
directionalHint : DirectionalHint . bottomAutoEdge ,
35
35
} ;
36
36
37
- function useCachedBounds ( props : IPositioningContainerProps , targetWindow : Window | undefined ) {
37
+ function useBounds ( props : IPositioningContainerProps , targetWindow : Window | undefined ) {
38
38
/** The bounds used when determining if and where the PositioningContainer should be placed. */
39
- const positioningBounds = React . useRef < IRectangle > ( ) ;
40
-
41
- const getCachedBounds = ( ) : IRectangle => {
42
- if ( ! positioningBounds . current ) {
43
- let currentBounds = props . bounds ;
44
-
45
- if ( ! currentBounds ) {
46
- currentBounds = {
47
- top : 0 + props . minPagePadding ! ,
48
- left : 0 + props . minPagePadding ! ,
49
- right : targetWindow ! . innerWidth - props . minPagePadding ! ,
50
- bottom : targetWindow ! . innerHeight - props . minPagePadding ! ,
51
- width : targetWindow ! . innerWidth - props . minPagePadding ! * 2 ,
52
- height : targetWindow ! . innerHeight - props . minPagePadding ! * 2 ,
53
- } ;
54
- }
55
- positioningBounds . current = currentBounds ;
39
+
40
+ const getBounds = ( ) : IRectangle => {
41
+ let currentBounds = props . bounds ;
42
+
43
+ if ( ! currentBounds ) {
44
+ currentBounds = {
45
+ top : 0 + props . minPagePadding ! ,
46
+ left : 0 + props . minPagePadding ! ,
47
+ right : targetWindow ! . innerWidth - props . minPagePadding ! ,
48
+ bottom : targetWindow ! . innerHeight - props . minPagePadding ! ,
49
+ width : targetWindow ! . innerWidth - props . minPagePadding ! * 2 ,
50
+ height : targetWindow ! . innerHeight - props . minPagePadding ! * 2 ,
51
+ } ;
56
52
}
57
- return positioningBounds . current ;
53
+ return currentBounds ;
58
54
} ;
59
55
60
- return getCachedBounds ;
56
+ return getBounds ;
61
57
}
62
58
63
59
function usePositionState (
@@ -312,7 +308,7 @@ export const PositioningContainer: React.FunctionComponent<IPositioningContainer
312
308
const rootRef = useMergedRefs ( forwardedRef , positionedHost ) ;
313
309
314
310
const [ targetRef , targetWindow ] = useTarget ( props . target , positionedHost ) ;
315
- const getCachedBounds = useCachedBounds ( props , targetWindow ) ;
311
+ const getCachedBounds = useBounds ( props , targetWindow ) ;
316
312
const [ positions , updateAsyncPosition ] = usePositionState (
317
313
props ,
318
314
positionedHost ,
0 commit comments