Skip to content

Conversation

@Elad-Abutbul
Copy link

No description provided.

@ShirYahav ShirYahav requested a review from OfekSagiv December 17, 2025 08:51
Copy link

@OfekSagiv OfekSagiv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! I left you some comments

Comment on lines 11 to 13
{squares.map((square, index) => {
return <Square value={square} onClick={() => onSquareClick(index)} />;
})}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no key prop here. React relies on keys to track elements between renders. Without them, React might re-render the entire list unnecessarily.

Comment on lines 85 to 91
{winner ? (
""
) : (
<h2>
time for player {isXNext ? "X" : "O"}- {timer} sec
</h2>
)}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid repeated ternaries in JSX
{!winner && <h2>Time for player {isXNext ? "X" : "O"} - {timer} sec</h2>}

Comment on lines 92 to 93
<Board squares={squares} onSquareClick={handleSquareClick} />
{winner ? "" : <p>Next Player: {isXNext ? "X" : "O"}</p>}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid repeated ternaries in JSX

Comment on lines 23 to 27

for (let i = 0; i < lines.length; i++) {
const a = lines[i][0];
const b = lines[i][1];
const c = lines[i][2];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick:
instead the existing code:

for (let i = 0; i < lines.length; i++) {
      const a = lines[i][0];
      const b = lines[i][1];
      const c = lines[i][2];

you can use for... of loop
for (const [a, b, c] of lines) {

Comment on lines 94 to 100
<button onClick={handleReset}>reset</button>
{winner ? (
""
) : (
<button onClick={handleStop}>{stop ? "resume" : "stop"}</button>
)}
</div>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional rendering here can be simplified.
Rendering an empty string is unnecessary and hurts readability.
Consider using && and extracting the button label logic.
const pauseButtonLabel = stop ? "resume" : "stop";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several magic numbers in the component (board size, turn duration, timer interval).
Consider extracting them into named constants to improve readability and maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants