Wrap Cell in React.Memo
This commit is contained in:
parent
4349269aff
commit
0f8c2d09b4
@ -1,4 +1,4 @@
|
|||||||
import {MouseEvent} from 'react';
|
import React, {MouseEvent} from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
interface CellProps {
|
interface CellProps {
|
||||||
@ -9,7 +9,7 @@ interface CellProps {
|
|||||||
|
|
||||||
let currentDragValue = true;
|
let currentDragValue = true;
|
||||||
|
|
||||||
const Cell = ({value, position, updateCell}: CellProps) => {
|
const Cell = React.memo(({value, position, updateCell}: CellProps) => {
|
||||||
const cellClasses = classNames({
|
const cellClasses = classNames({
|
||||||
'cell': true,
|
'cell': true,
|
||||||
'active': value
|
'active': value
|
||||||
@ -35,6 +35,6 @@ const Cell = ({value, position, updateCell}: CellProps) => {
|
|||||||
onMouseEnter={handleCellMouseOver}
|
onMouseEnter={handleCellMouseOver}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
});
|
||||||
|
|
||||||
export default Cell;
|
export default Cell;
|
||||||
@ -45,7 +45,7 @@ const ControlPanel = ({
|
|||||||
/>
|
/>
|
||||||
</ControlElement>
|
</ControlElement>
|
||||||
|
|
||||||
<ControlElement title='Change Speed'>
|
<ControlElement title='Time per iteration' alignment='center'>
|
||||||
<SpeedSelector
|
<SpeedSelector
|
||||||
handleUpdateSpeed={handleUpdateSpeed}
|
handleUpdateSpeed={handleUpdateSpeed}
|
||||||
speed={gameOptions.speed}
|
speed={gameOptions.speed}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user