-
Notifications
You must be signed in to change notification settings - Fork 72
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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}; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
No description provided.