Skip to content

Commit

Permalink
fix(TGI): 图表重复渲染的问题 (#386)
Browse files Browse the repository at this point in the history
Co-authored-by: Zhang Rui <[email protected]>
  • Loading branch information
Quesle and Zhang Rui authored Apr 22, 2024
1 parent 94228fa commit ffcf374
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/combine-bar/CombineBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useMemo } from 'react';
import { default as CombineBarCls } from './framework';

import { ChartType, ChartProps, BarConfig, ChartRef } from '../interfaces';
Expand All @@ -24,7 +24,9 @@ export interface DragBarProps extends BarProps {
const CombineBar: React.ForwardRefRenderFunction<ChartRef, BarProps> = (props, forwardRef) => {
const { data, legends: legendProps = [], config = {} as BarConfig, title } = props;

const combineBar = new CombineBarCls();
const combineBar = useMemo(() => {
return new CombineBarCls();
}, []);

config.type = ChartType.BAR;
config.chart = {
Expand Down
4 changes: 3 additions & 1 deletion src/combine-colunm/CombineColunm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const CombineColumn: React.ForwardRefRenderFunction<ChartRef, ColumnProps> = (pr
const { data, legends: legendProps = [], config, useScroll, title } = props;
const [assignConfig, setAssignConfig] = useState({});

const combineColumn = new CombineColumnCls();
const combineColumn = useMemo(() => {
return new CombineColumnCls();
}, []);

useEffect(() => {
const newConfig = config || {};
Expand Down

0 comments on commit ffcf374

Please sign in to comment.