File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -21,15 +21,22 @@ import {
2121 BASE_VIEW_WIDTH ,
2222 MIN_ROW_HEIGHT ,
2323} from 'app/pages/DashBoardPage/constants' ;
24- import { useMemo } from 'react' ;
24+ import { useEffect , useMemo , useState } from 'react' ;
2525import useResizeObserver from './useResizeObserver' ;
2626
2727export const useWidgetRowHeight = ( ) => {
28+ const [ cacheW , setCacheW ] = useState ( 0 ) ;
2829 const { ref, width = 0 } = useResizeObserver < HTMLDivElement > ( ) ;
30+
31+ useEffect ( ( ) => {
32+ if ( width > 0 ) {
33+ setCacheW ( width ) ;
34+ }
35+ } , [ width ] ) ;
2936 const widgetRowHeight = useMemo ( ( ) => {
30- let dynamicHeight = ( width * BASE_ROW_HEIGHT ) / BASE_VIEW_WIDTH ;
37+ let dynamicHeight = ( cacheW * BASE_ROW_HEIGHT ) / BASE_VIEW_WIDTH ;
3138 return Math . max ( dynamicHeight , MIN_ROW_HEIGHT ) ;
32- } , [ width ] ) ;
39+ } , [ cacheW ] ) ;
3340 return {
3441 ref,
3542 widgetRowHeight,
You can’t perform that action at this time.
0 commit comments