Skip to content

Conversation

@veralizeth
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? updateValue is the event handler for clicking on each square. Every time one square is clicked setPlayer1Turn, display X and Pass the turn to player2. SetPlayer1Turn, now the player1 turn is over.
What are two ways to do "dynamic styling" with React? When should they be used? We can use inline styles or separate styleSheets. We should separate them from the logic and just link each file to the stylesheet file.
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. The user input happens inside of App.js and we are not displaying different pages, we are just displaying at the same place, rendering different components based on the events.

CS Fundamentals Questions

Question Answer
What do you think is the BigO complexity of the method you use to compute a winner? To compute the winner my solution is O(n^2) since I have a loop inside of another loop to get a flat array.
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.
I think the components are objects (JSON). I think react traverses over the components and makes a filter base in what is looking for. Components are like functions. Could be O(n) where n are the number of components?

Comment on lines +87 to +105
const checkForWinner = (setSquares) => {
// Complete in Wave 3
// Invoking the function to get a flat array with the values.
const values = extractValuesFromSquares(setSquares);

for (let i in WINNINGOPTIONS) {
// Destructuring (Example winningOptions first Iteration[i] i=0
// a = 0, b = 1 c = 2)
const [a, b, c] = WINNINGOPTIONS[i];
// Return the value of the winner
if (values[a] && values[a] === values[b] && values[a] === values[c]) {
// Return the value of the winner player.
return values[a];
} else if (!values.includes('')) {
// Return false is there is tie.
return false;
}
}
// The game is runnig!

Choose a reason for hiding this comment

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

So concise!

@jmaddox19
Copy link

React Tic Tac Toe

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Demonstrates proper JavaScript coding style. ✔️
Correctly passes props to child components. ✔️
Correctly passes callback functions to child components and calls them to respond to user events.) ✔️
Maintains the status of the game in state. ✔️
Practices git with at least 6 small commits and meaningful commit messages ✔️ So many good little commits!
Uses existing stylesheets to render components ✔️

Functional Requirements

Functional Requirement yes/no
The Square component renders properly and executes the callback on a click event. ✔️
The Board component renders a collection of squares ✔️
The App component renders a board and uses state to maintain the status of the game. ✔️
Utilizes callbacks to UI events to update state ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 5+ in Code Review && 3+ in Functional Requirements ✔️
Yellow (Approaches Standards) 4+ in Code Review && 2+ in Functional Requirements, or the instructor judges that this project needs special attention
Red (Not at Standard) 0-3 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging, or the instructor judges that this project needs special attention

Additional Feedback

Great work!! Love the pretty styling you added!

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

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.

2 participants