-
Notifications
You must be signed in to change notification settings - Fork 48
Time - Hannah T #41
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
base: master
Are you sure you want to change the base?
Time - Hannah T #41
Conversation
React Tic Tac ToeMajor Learning Goals/Code Review
Functional Requirements
Overall Feedback
Additional FeedbackGreat work! See my inline comments for a couple additional notes. Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
|
|
|
||
| const checkRow = (turn) => { | ||
| for (let row = 0; row < 3; row++) { | ||
| if ((squares[row][0].value === turn) && |
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.
This is minor but this is one of several places where your indentation is just slightly off. I use a VSCode plugin called indent-rainbow to help me catch indentation weirdness like this.
| const checkCol = (turn) => { | ||
| for (let col = 0; col < 3; col++) { | ||
| if ((squares[0][col].value === turn) && | ||
| (squares[1][col].value === turn) && | ||
| (squares[2][col].value === turn)){ | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| const checkDiagonal = (turn) => { | ||
| if ((squares[0][0].value === turn) && | ||
| (squares[1][1].value === turn) && | ||
| (squares[2][2].value === turn)) { | ||
| return true; | ||
| } | ||
| if ((squares[0][2].value === turn) && | ||
| (squares[1][1].value === turn) && | ||
| (squares[2][0].value === turn)){ | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| const checkForWinner = (turn) => { | ||
| if (checkRow(turn) || checkCol(turn) || checkDiagonal(turn)) { | ||
| setWinner(turn) | ||
| } | ||
| } |
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 appreciate that you separated this logic into different functions! It definitely helps make it easier to read.
React Tic Tac Toe
homepage: https://stpatrickschild.github.io/react-tic-tac-toe
1.) How are events / event handlers and
useStateconnected?useStateand can be used to change the state ofComponents. As events happen, the
useStateis used to handle that event.2.) What are two ways to do "dynamic styling" with React? When should they be used?
variable to JSX tag element or to update the component. They should be used when we want to
change the user interface based on the events.
3.) Much like Rails works with the HTTP request->response cycle, React works with the
browser's input->output cycle. Describe React's cycle from receiving user input to
outputting different page content.
Pretty much, when it’s clickedOn, the component sends the response to the app then the app.
Changes the output by whatever the inner method is defined.
CS Fundamentals Questions
1.) What do you think is the BigO complexity of the method you use to compute a winner?
computation.
2.) Consider what happens when React processes a state change from
setState-- it must re-render all of the components that now have different content because of that change.What kind of data structure are the components in, and what sort of algorithms would be appropriate for React's code to "traverse" those components?
Speculate wildly about what the Big-O time complexity of that code might be. |