Skip to content

Commit

Permalink
[DTRA-V2] henry/dtra-2029/fix: rerender chart on symbol or change (de…
Browse files Browse the repository at this point in the history
…riv-com#17012)

* fix: rerender chart on symbol or change

* fix: rerender chart for digits only
  • Loading branch information
henry-deriv authored Oct 3, 2024
1 parent 042e2ad commit 06cdd98
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/trader/src/AppV2/Containers/Chart/trade-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import AccumulatorsChartElements from 'Modules/SmartChart/Components/Markers/acc
import ToolbarWidgets from 'Modules/SmartChart/Components/toolbar-widgets';
import useActiveSymbols from 'AppV2/Hooks/useActiveSymbols';
import useDefaultSymbol from 'AppV2/Hooks/useDefaultSymbol';
import { isDigitTradeType } from 'Modules/Trading/Helpers/digits';

type TBottomWidgetsParams = {
digits: number[];
Expand Down Expand Up @@ -74,7 +75,7 @@ const TradeChart = observer(() => {
wsSendRequest,
wsSubscribe,
} = useTraderStore();

const is_digit_trade_type = isDigitTradeType(contract_type);
const is_accumulator = isAccumulatorContract(contract_type);
const settings = {
countdown: is_chart_countdown_visible,
Expand All @@ -94,6 +95,13 @@ const TradeChart = observer(() => {
);
}, []);

const chartKey = React.useMemo(() => {
if (is_digit_trade_type) {
return symbol;
}
return null;
}, [symbol, is_digit_trade_type]);

React.useEffect(() => {
if ((is_accumulator || show_digits_stats) && ref.current?.hasPredictionIndicators()) {
const cancelCallback = () => onChange({ target: { name: 'contract_type', value: prev_contract_type } });
Expand Down Expand Up @@ -125,6 +133,7 @@ const TradeChart = observer(() => {
if (!symbol || !active_symbols.length) return null;
return (
<SmartChart
key={chartKey}
ref={ref}
barriers={barriers}
contracts_array={markers_array}
Expand Down

0 comments on commit 06cdd98

Please sign in to comment.