Skip to content

Conversation

@made-line
Copy link

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? When an event happens (e.g., button is clicked), it triggers an event handler which is a function that updates useState.
What are two ways to do "dynamic styling" with React? When should they be used? Inline styling and styles object in our render function.
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. Once an event is triggered, the function handles the event related to what the user clicked/typed.

CS Fundamentals Questions

Question Answer
What do you think is the BigO complexity of the method you use to compute a winner? 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.
Array or object; they can be traversed using a forEach or for in loop. O(n) best case and O(n^2) worst case.

Copy link

@kaidamasaki kaidamasaki 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.

Good work implementing a React project using state and callback functions!

// wave 3: check for winner
const checkForWinner = () => {
// row and col check
for (let i = 0; i < 3; i++) {

Choose a reason for hiding this comment

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

Congrats on getting this loop right! It's a tricky one. 😄

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