@trackunit/react-chart-components 1.7.81 → 1.7.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -99,20 +99,35 @@ const EChart = ({ option, style, className, onChartReady, onClick, onEvents, not
99
99
  react.useEffect(() => {
100
100
  initChart();
101
101
  isInitialRender.current = true;
102
+ let rafId = null;
102
103
  const resizeObserver = new ResizeObserver(() => {
103
104
  const chart = internalChartRef.current;
104
105
  if (!chart) {
105
106
  return;
106
107
  }
107
- if (!chart.isDisposed()) {
108
- chart.resize();
108
+ // Cancel any pending resize
109
+ if (rafId !== null) {
110
+ cancelAnimationFrame(rafId);
109
111
  }
112
+ // Defer the resize to the next frame to prevent ResizeObserver loop
113
+ rafId = requestAnimationFrame(() => {
114
+ if (!chart.isDisposed()) {
115
+ chart.resize();
116
+ }
117
+ rafId = null;
118
+ });
110
119
  });
111
120
  const container = containerRef.current;
112
121
  if (container) {
113
122
  resizeObserver.observe(container);
114
123
  }
115
124
  return () => {
125
+ if (rafId !== null) {
126
+ cancelAnimationFrame(rafId);
127
+ }
128
+ if (container) {
129
+ resizeObserver.unobserve(container);
130
+ }
116
131
  resizeObserver.disconnect();
117
132
  const chart = internalChartRef.current;
118
133
  if (!chart) {
package/index.esm.js CHANGED
@@ -78,20 +78,35 @@ const EChart = ({ option, style, className, onChartReady, onClick, onEvents, not
78
78
  useEffect(() => {
79
79
  initChart();
80
80
  isInitialRender.current = true;
81
+ let rafId = null;
81
82
  const resizeObserver = new ResizeObserver(() => {
82
83
  const chart = internalChartRef.current;
83
84
  if (!chart) {
84
85
  return;
85
86
  }
86
- if (!chart.isDisposed()) {
87
- chart.resize();
87
+ // Cancel any pending resize
88
+ if (rafId !== null) {
89
+ cancelAnimationFrame(rafId);
88
90
  }
91
+ // Defer the resize to the next frame to prevent ResizeObserver loop
92
+ rafId = requestAnimationFrame(() => {
93
+ if (!chart.isDisposed()) {
94
+ chart.resize();
95
+ }
96
+ rafId = null;
97
+ });
89
98
  });
90
99
  const container = containerRef.current;
91
100
  if (container) {
92
101
  resizeObserver.observe(container);
93
102
  }
94
103
  return () => {
104
+ if (rafId !== null) {
105
+ cancelAnimationFrame(rafId);
106
+ }
107
+ if (container) {
108
+ resizeObserver.unobserve(container);
109
+ }
95
110
  resizeObserver.disconnect();
96
111
  const chart = internalChartRef.current;
97
112
  if (!chart) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-chart-components",
3
- "version": "1.7.81",
3
+ "version": "1.7.82",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -9,13 +9,13 @@
9
9
  "dependencies": {
10
10
  "echarts": "5.6.0",
11
11
  "react": "19.0.0",
12
- "@trackunit/date-and-time-utils": "1.7.50",
13
- "@trackunit/react-date-and-time-hooks": "1.7.73",
14
- "@trackunit/ui-design-tokens": "1.7.50",
15
- "@trackunit/shared-utils": "1.9.50",
16
- "@trackunit/css-class-variance-utilities": "1.7.50",
17
- "@trackunit/react-components": "1.10.18",
18
- "@trackunit/react-test-setup": "1.4.50"
12
+ "@trackunit/date-and-time-utils": "1.7.51",
13
+ "@trackunit/react-date-and-time-hooks": "1.7.74",
14
+ "@trackunit/ui-design-tokens": "1.7.51",
15
+ "@trackunit/shared-utils": "1.9.51",
16
+ "@trackunit/css-class-variance-utilities": "1.7.51",
17
+ "@trackunit/react-components": "1.10.19",
18
+ "@trackunit/react-test-setup": "1.4.51"
19
19
  },
20
20
  "module": "./index.esm.js",
21
21
  "main": "./index.cjs.js",