Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scissors - Sneha Agarwal #67

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

sneha8412
Copy link

No description provided.

Copy link

@jmaddox19 jmaddox19 left a comment

Choose a reason for hiding this comment

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

Everything looks great! Very cool that you deployed! And very cool that the code is generic to be able to work with a 4x4 board (for example) if we wanted it to!

Just a couple little comments below!

//console.log('row_num', rowNum);
//console.log('col_num', colNum);
// set the value of the square on square button click
squares[rowNum][colNum] = {id:id, value:player};

Choose a reason for hiding this comment

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

When using React useState hook, we shouldn't directly modify squares. Instead, we can make a copy of squares using the spread operator const newSquares = [...squares]. Then we assign our new value to our newSquares and call setSquares(newSquares). This is because of how the useState hook works. In this code, it ends up working because we also call setPlayer which triggers a re-render.

if (sqValue.value != e){
emptySquareCounts -= 1;
}
console.log('empty square counts:', emptySquareCounts);

Choose a reason for hiding this comment

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

I see that you commented out most of the console.log statements and probably just forgot to comment out this one.
It's generally best to remove console.log statements that were written for debugging purposes before submitting a PR, rather than comment them out, since they will probably serve no useful purpose again now that the program all works properly.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, Thanks for the feedback Jared!

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