fix: incorrect symbol being shown for the current page

This commit is contained in:
Matthew Russell
2024-01-23 14:42:04 -08:00
parent 0235516e1c
commit a1cd8386da
@@ -135,6 +135,14 @@ export const TradingView = ({
if (state !== undefined) {
// Load stored state
widgetRef.current.load(state);
// Whatever was the last active chart will be loaded, so reset the current symbol for
// the market loaded on the page
widgetRef.current.setSymbol(
marketId,
interval as TVResolutionString,
noop
);
} else {
// No stored state, likely the first time using the TV chart,
// show the volume study by default
@@ -160,6 +168,7 @@ export const TradingView = ({
return () => {
if (!widgetRef.current) return;
widgetRef.current.remove();
widgetRef.current = undefined;
};
}, []);