Skip to content

Space - Shonda#23

Open
Shonda860 wants to merge 13 commits intoAda-C13:masterfrom
Shonda860:master
Open

Space - Shonda#23
Shonda860 wants to merge 13 commits intoAda-C13:masterfrom
Shonda860:master

Conversation

@Shonda860
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? Events perform actions in response to a user action. Event handlers are how the event is handle by the function. 'useState' is a Hook that also accesses to function components. This hook allows you to track the initial state.
What are two ways to do "dynamic styling" with React? When should they be used? Inline styling by using className or id which is linked to external CSS. Or you can add style to rendering.
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. It uses a DOM and a Virtual DOM to "react" to changes

CS Fundamentals Questions

Question Answer
What do you think is the BigO complexity of the method you use to compute a winner? I believe since there are 3 functions within one function. However, each function 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.
React creates a tree of React Elements. However, once that next call is rendered the state or props will be different and thus the tree of React elements will differ. React needs to find those differences in the most efficient way possible to make those trees look like one another. To do so it uses O(log) where n is the number of elements in the tree. This is why the key prop is important because by pointing to this the developer can point to the child element which may be stable. Making the search less expensive. There are certain elements in react that will force React to build a new tree such as button or div.

@CheezItMan
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 ✔️
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

Code Style Bonus Awards

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

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

Summary

Really nicely done, you hit all the learning goals here. I like the helper methods and you wrote nice clean code.

Comment on lines +50 to +54
if (turn === PLAYER_2) {
setTurn(PLAYER_1);
} else if (turn === PLAYER_1) {
setTurn(PLAYER_2);
}

Choose a reason for hiding this comment

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

Just a suggestion, you can use a ternary here.

Comment on lines +65 to +67
checkRowsandColumns();
checkDiagonals();
checkForTie();

Choose a reason for hiding this comment

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

I like the helper methods.

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