Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/Cell.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useCallback } from "react";
import PropTypes from "prop-types";

/**
Expand All @@ -9,6 +9,10 @@ import PropTypes from "prop-types";
* @returns A JSX button object representing a Cell.
*/
function Cell({ cellStatus, cellValue, onClick }) {
const handleClick = useCallback(() => {
onClick(cellValue, cellStatus(cellValue));
}, [cellValue, cellStatus, onClick]);

return (
<button
className='cell'
Expand All @@ -17,7 +21,8 @@ function Cell({ cellStatus, cellValue, onClick }) {
width: "20%",
backgroundColor: colors[cellStatus(cellValue)],
}}
onClick={() => onClick(cellValue, cellStatus(cellValue))}
onClick={handleClick}
title={`Cell ${cellValue} is ${cellStatus(cellValue)}`}
></button>
);
}
Expand Down