Skip to content

Commit 0569c3f

Browse files
authored
Merge pull request #2801 from pyth-network/cprussin/fix-insights-hub-chart
fix(insights): fix insights hub chart re-initializing repeatedly
2 parents b7ccbc4 + f943a80 commit 0569c3f

File tree

1 file changed

+4
-4
lines changed
  • apps/insights/src/components/PriceFeed

1 file changed

+4
-4
lines changed

apps/insights/src/components/PriceFeed/chart.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { useLogger } from "@pythnetwork/component-library/useLogger";
4-
import { useResizeObserver } from "@react-hookz/web";
4+
import { useResizeObserver, useMountEffect } from "@react-hookz/web";
55
import type { IChartApi, ISeriesApi, UTCTimestamp } from "lightweight-charts";
66
import { LineSeries, LineStyle, createChart } from "lightweight-charts";
77
import { useTheme } from "next-themes";
@@ -101,10 +101,10 @@ const useChartElem = (symbol: string, feedId: string) => {
101101
}
102102
}, [logger, symbol]);
103103

104-
useEffect(() => {
104+
useMountEffect(() => {
105105
const chartElem = chartContainerRef.current;
106106
if (chartElem === null) {
107-
return;
107+
throw new Error("Chart element was null on mount");
108108
} else {
109109
const chart = createChart(chartElem, {
110110
layout: {
@@ -146,7 +146,7 @@ const useChartElem = (symbol: string, feedId: string) => {
146146
chart.remove();
147147
};
148148
}
149-
}, [backfillData, priceFormatter]);
149+
});
150150

151151
useEffect(() => {
152152
if (current && chartRef.current) {

0 commit comments

Comments
 (0)