From e803a9172b6bee53dc689466bc81f8d385d6b671 Mon Sep 17 00:00:00 2001 From: goodmice Date: Fri, 12 Nov 2021 18:06:39 +0500 Subject: [PATCH] Column use memo added --- src/components/charts/Column.jsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/components/charts/Column.jsx b/src/components/charts/Column.jsx index 4be6328..0a7eea5 100644 --- a/src/components/charts/Column.jsx +++ b/src/components/charts/Column.jsx @@ -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 -} - -Column.defaultProps = { - pointCount: 2048, - savePreviousData: false -} +}) \ No newline at end of file