diff --git a/src/combine-bar/CombineBar.tsx b/src/combine-bar/CombineBar.tsx index d745aa11..4184d82b 100644 --- a/src/combine-bar/CombineBar.tsx +++ b/src/combine-bar/CombineBar.tsx @@ -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'; @@ -24,7 +24,9 @@ export interface DragBarProps extends BarProps { const CombineBar: React.ForwardRefRenderFunction = (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 = { diff --git a/src/combine-colunm/CombineColunm.tsx b/src/combine-colunm/CombineColunm.tsx index 74d61bb0..e7a606e2 100644 --- a/src/combine-colunm/CombineColunm.tsx +++ b/src/combine-colunm/CombineColunm.tsx @@ -16,7 +16,9 @@ const CombineColumn: React.ForwardRefRenderFunction = (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 || {};