File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
src/plugins/vis_type_tagcloud/public/components Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 1717 * under the License.
1818 */
1919
20- import React , { useCallback , useEffect , useRef } from 'react' ;
20+ import React , { useEffect , useMemo , useRef } from 'react' ;
2121import { EuiResizeObserver } from '@elastic/eui' ;
22+ import { throttle } from 'lodash' ;
2223
2324import { TagCloudVisDependencies } from '../plugin' ;
2425import { TagCloudVisRenderValue } from '../tag_cloud_fn' ;
@@ -57,14 +58,18 @@ export const TagCloudChart = ({
5758 }
5859 } , [ visData , visParams , renderComplete ] ) ;
5960
60- const onResize = useCallback ( ( ) => {
61- if ( visController . current ) {
62- visController . current . render ( ) . then ( renderComplete ) ;
63- }
64- } , [ renderComplete ] ) ;
61+ const updateChartSize = useMemo (
62+ ( ) =>
63+ throttle ( ( ) => {
64+ if ( visController . current ) {
65+ visController . current . render ( ) . then ( renderComplete ) ;
66+ }
67+ } , 300 ) ,
68+ [ renderComplete ]
69+ ) ;
6570
6671 return (
67- < EuiResizeObserver onResize = { onResize } >
72+ < EuiResizeObserver onResize = { updateChartSize } >
6873 { ( resizeRef ) => (
6974 < div className = "tgcChart__wrapper" ref = { resizeRef } >
7075 < div className = "tgcChart__container" ref = { chartDiv } />
You can’t perform that action at this time.
0 commit comments