Skip to content

Conversation

@anakp07
Copy link

@anakp07 anakp07 commented Dec 31, 2020

React Tic Tac Toe

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Prompt Response
How are events / event handlers and useState connected? The event handler that what is used to change/update the state.
What are two ways to do "dynamic styling" with React? When should they be used? We could have an external CSS stylesheet that would reference different components can use. This should be used for larger project with similar component that we want to mirror styling. We can also have inline styling. This can be used for simple and easy styling.
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. With React, we have event listeners that triggered when specific events happens, and it tells React to re-render the page/App and thats when it checks the virtual dom and re-renders the things that are different.

CS Fundamentals Questions

Question Answer
What do you think is the BigO complexity of the method you use to compute a winner? The time complexity is O(n) and the space complexity is O(n).
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.
We dont really understand the question?

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

For TicTacToe we reviewed test results, the checkForWinner function, and onClickCallback function. Both functions look good and do what's required. Good work implementing a React project using state and callback functions!

// You will need to create a method to change the square
// When it is clicked on.
// Then pass it into the squares as a callback
const updateSquare = (squareId) => {

Choose a reason for hiding this comment

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

👍

return null
}

const winnerHelper = (array) => {

Choose a reason for hiding this comment

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

Nice helper function!

Comment on lines +61 to +62
if (winnerHelper(rowVals)) {
return winnerHelper(rowVals);

Choose a reason for hiding this comment

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

Do you need to call winnerHelper twice here?

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.

3 participants