Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished tic tac toe #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CieloRaymundo
Copy link

No description provided.

@@ -0,0 +1,31 @@
.symbol {

Choose a reason for hiding this comment

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

Each of your styles aligns to a classname referenced in your app. 💯

const App = () => {
return <div>A tic-tac-toe game</div>;
return (
Copy link

@Keyairra-S-Wright Keyairra-S-Wright May 2, 2020

Choose a reason for hiding this comment

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

Each of this app's components renders a logical child component. Using modules generally results in code that is easier to read and maintain. 💯

Comment on lines +52 to +65
<Squares click={() => clickHandler(0)} value={boardState[0]}/>
<Squares click={() => clickHandler(1)} value={boardState[1]}/>
<Squares click={() => clickHandler(2)} value={boardState[2]}/>
</div>
<div className="rows">
<Squares click={() => clickHandler(3)} value={boardState[3]}/>
<Squares click={() => clickHandler(4)} value={boardState[4]}/>
<Squares click={() => clickHandler(5)} value={boardState[5]}/>
</div>
<div className="rows">
<Squares click={() => clickHandler(6)} value={boardState[6]}/>
<Squares click={() => clickHandler(7)} value={boardState[7]}/>
<Squares click={() => clickHandler(8)} value={boardState[8]}/>
</div>

Choose a reason for hiding this comment

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

Having access to boardState gives a perfect opportunity to use .map() to render<Squares/> rather than hardcoding each instance.

@@ -0,0 +1,5 @@
function Squares(props) {
return (
<div className="symbol" onClick={props.click}>{props.value}</div>

Choose a reason for hiding this comment

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

This is just a matter of preference: when using multiple props, the destructuring assignment can be used to help reduce code repetition. This is especially helpful in components with an increased number of props.

Suggested change
<div className="symbol" onClick={props.click}>{props.value}</div>
const {click, value} = props;
return (
<div className="symbol" onClick={click}>{value}</div>
)

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