Column use memo added

This commit is contained in:
goodmice 2021-11-12 18:06:39 +05:00
parent 80622351f8
commit e803a9172b

View File

@ -1,4 +1,4 @@
import { useState, useEffect } from 'react'
import React, { useState, useEffect } from 'react'
import { ChartTimeBase } from './ChartTimeBase'
const chartPluginsOptions = {
@ -45,8 +45,10 @@ export const GetOrCreateDatasetByLineConfig = (data, lineConfig) => {
return dataset
}
export const Column = ({ lineGroup, data, postParsing, interval, yDisplay, yStart, pointCount, savePreviousData }) => {
export const Column = React.memo(({ lineGroup, data, postParsing, interval, yDisplay, yStart, pointCount, savePreviousData }) => {
const [dataParams, setDataParams] = useState({data: {datasets:[]}, yStart, })
if (!pointCount || !Number.isInteger(pointCount))
pointCount = 2048
useEffect(()=>{
if((lineGroup.length === 0) || (data.length === 0)) return
@ -83,9 +85,4 @@ export const Column = ({ lineGroup, data, postParsing, interval, yDisplay, yStar
}, [data, lineGroup, interval, yDisplay, yStart, postParsing, pointCount, savePreviousData])
return <ChartTimeBase dataParams = { dataParams } options = { chartPluginsOptions } />
}
Column.defaultProps = {
pointCount: 2048,
savePreviousData: false
}
})