-
Notifications
You must be signed in to change notification settings - Fork 10
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
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,31 @@ | |||
.symbol { |
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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. 💯
<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> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
<div className="symbol" onClick={props.click}>{props.value}</div> | |
const {click, value} = props; | |
return ( | |
<div className="symbol" onClick={click}>{value}</div> | |
) |
No description provided.