From 27a7256e04415989361858273a920d007cb19b29 Mon Sep 17 00:00:00 2001 From: Marco Vettorello Date: Tue, 28 Jun 2022 11:37:18 +0200 Subject: [PATCH] fix(events): remove async callbacks from code (#1730) --- .../state/selectors/on_projection_area_caller.ts | 4 +--- packages/charts/src/components/chart_container.tsx | 11 +---------- packages/charts/src/components/chart_status.tsx | 7 +------ 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/packages/charts/src/chart_types/xy_chart/state/selectors/on_projection_area_caller.ts b/packages/charts/src/chart_types/xy_chart/state/selectors/on_projection_area_caller.ts index 117a9edf38..67e08c349a 100644 --- a/packages/charts/src/chart_types/xy_chart/state/selectors/on_projection_area_caller.ts +++ b/packages/charts/src/chart_types/xy_chart/state/selectors/on_projection_area_caller.ts @@ -43,9 +43,7 @@ export function createOnProjectionAreaCaller(): (state: GlobalChartState) => voi isDiff(prevProps.projection, nextProps.projection) || isDiff(nextProps.parent, nextProps.parent); if (onProjectionAreaChange && areDifferent) { - requestAnimationFrame(() => { - onProjectionAreaChange(nextProps); - }); + onProjectionAreaChange(nextProps); } prevProps = nextProps; }, diff --git a/packages/charts/src/components/chart_container.tsx b/packages/charts/src/components/chart_container.tsx index e16a4b61c7..58b83a4406 100644 --- a/packages/charts/src/components/chart_container.tsx +++ b/packages/charts/src/components/chart_container.tsx @@ -151,16 +151,7 @@ class ChartContainerComponent extends React.Component { const { onMouseUp } = this.props; window.removeEventListener('mouseup', this.handleBrushEnd); - - requestAnimationFrame(() => { - onMouseUp( - { - x: -1, - y: -1, - }, - Date.now(), - ); - }); + onMouseUp({ x: -1, y: -1 }, Date.now()); }; render() { diff --git a/packages/charts/src/components/chart_status.tsx b/packages/charts/src/components/chart_status.tsx index a796b999a9..68bc64f094 100644 --- a/packages/charts/src/components/chart_status.tsx +++ b/packages/charts/src/components/chart_status.tsx @@ -38,12 +38,7 @@ class ChartStatusComponent extends React.Component { } dispatchRenderChange = () => { - const { onRenderChange, rendered } = this.props; - if (onRenderChange) { - window.requestAnimationFrame(() => { - onRenderChange(rendered); - }); - } + this.props.onRenderChange?.(this.props.rendered); }; render() {