From 0f8c2d09b4b8ec34c445b981b0bb89e2899aed7f Mon Sep 17 00:00:00 2001 From: sschwei1 <24sebastian05@gmail.com> Date: Tue, 22 Nov 2022 23:52:19 +0100 Subject: [PATCH] Wrap Cell in React.Memo --- src/components/game/Cell.tsx | 6 +++--- src/components/game/controlPanel/ControlPanel.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/game/Cell.tsx b/src/components/game/Cell.tsx index 698ea5e..2e1bf71 100644 --- a/src/components/game/Cell.tsx +++ b/src/components/game/Cell.tsx @@ -1,4 +1,4 @@ -import {MouseEvent} from 'react'; +import React, {MouseEvent} from 'react'; import classNames from 'classnames'; interface CellProps { @@ -9,7 +9,7 @@ interface CellProps { let currentDragValue = true; -const Cell = ({value, position, updateCell}: CellProps) => { +const Cell = React.memo(({value, position, updateCell}: CellProps) => { const cellClasses = classNames({ 'cell': true, 'active': value @@ -35,6 +35,6 @@ const Cell = ({value, position, updateCell}: CellProps) => { onMouseEnter={handleCellMouseOver} /> ) -} +}); export default Cell; \ No newline at end of file diff --git a/src/components/game/controlPanel/ControlPanel.tsx b/src/components/game/controlPanel/ControlPanel.tsx index 3bd11cf..ca70613 100644 --- a/src/components/game/controlPanel/ControlPanel.tsx +++ b/src/components/game/controlPanel/ControlPanel.tsx @@ -45,7 +45,7 @@ const ControlPanel = ({ /> - +