Skip to content

Conversation

@Schmarj3
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? hooks allow us to give state to our app, which gives us another way to determine how to respond to events with specific event handlers; we can also update state based on those events - it's all connected'
What are two ways to do "dynamic styling" with React? When should they be used? 1) Depending on the value of the state or variable or prop, 2) styling using a stylesheet or inline - it's dynamic because we can add logic in the component to change class names
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. We use event handlers to keep track of user inputs, which can invoke certain functions based on how we choose to handle the event. This event handler tells our app what changes to make, and our app then updates the browser to reflect these changes as output.

CS Fundamentals Questions

Question Answer
What do you think is the BigO complexity of the method you use to compute a winner? constant time, constant space
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.
Depends on how many components needed to change, so n*m where n is the number of components and m is the stuff you need to change it - worse case being every component needs to change

// Then pass it into the squares as a callback

const checkForWinner = (squares) => {
const checkForThree = (first, second, third) => {

Choose a reason for hiding this comment

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

Nice work writing a helper function for a clear and readable algorithm that works with a 2D array.

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