Skip to content

C16 - Spruce - Vange Spracklin#70

Open
HouseOfVange wants to merge 10 commits intoAda-C16:mainfrom
HouseOfVange:digital-starter
Open

C16 - Spruce - Vange Spracklin#70
HouseOfVange wants to merge 10 commits intoAda-C16:mainfrom
HouseOfVange:digital-starter

Conversation

@HouseOfVange
Copy link
Copy Markdown

completed wave 1!

Copy link
Copy Markdown

@audreyandoy audreyandoy left a comment

Choose a reason for hiding this comment

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

Great work Vange! You met all the learnings goals and passed the tests for this project.

I added ways to refactor and other approaches in your PR.

Keep up the great work!

Project Grade: 🟢

Comment thread src/App.js
Comment on lines +63 to +64
let nextPlayer = (currentPlayer === PLAYER_1) ? PLAYER_2 : PLAYER_1;
setCurrentPlayer(nextPlayer);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice ternary!

Comment thread src/App.js
Comment on lines +47 to +52
if (position.id != squareID){
return position;
}
if (position.value !== ''){
return position;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Because both conditionals have the same logic when evaluated to true, we can combine them into one using the || (or) operator:

Suggested change
if (position.id != squareID){
return position;
}
if (position.value !== ''){
return position;
}
if (position.id != squareID || position.value !== '' ) {
return position;
}

Comment thread src/App.js
return position;
}
madeMove = true;
const newSquare = {...position, value: currentPlayer};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great use of the spread operator to copy the key-value pairs and assign value to the current player!

Comment thread src/App.js
<h1>React Tic Tac Toe</h1>
<h2>The winner is ... -- Fill in for wave 3 </h2>
<button>Reset Game</button>
<h2> {showStatus()} </h2>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice helper function! Another approach to displaying winner text is by using a ternary operator:

Suggested change
<h2> {showStatus()} </h2>
<h2> { winner ? Winner is ${winner} : `Your turn ${currentPlayer}` } </h2>

Comment thread src/components/Square.js
Comment on lines 6 to +25
const Square = (props) => {
// For Wave 1 enable this
// Component to alert a parent
// component when it's clicked on.

return <button
className="square"
>
{props.value}
</button>
}
const handleOnClickSquareButton = () => {
// if (props.value){
// console.log('you cant play that square!');
// }else{
props.onClickCallback(props.id);
// }
};

return <button
className='square'
onClick={handleOnClickSquareButton}
>
{props.value}
</button>;
};
Copy link
Copy Markdown

@audreyandoy audreyandoy Jan 12, 2022

Choose a reason for hiding this comment

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

We could use object destructuring to reference props by their key name instead.

Suggested change
const Square = (props) => {
// For Wave 1 enable this
// Component to alert a parent
// component when it's clicked on.
return <button
className="square"
>
{props.value}
</button>
}
const handleOnClickSquareButton = () => {
// if (props.value){
// console.log('you cant play that square!');
// }else{
props.onClickCallback(props.id);
// }
};
return <button
className='square'
onClick={handleOnClickSquareButton}
>
{props.value}
</button>;
};
const Square = ( {value, id, onClickCallback, key} ) => {
const handleOnClickSquareButton = () => {
onClickCallback(id);
};
return <button
className='square'
onClick={handleOnClickSquareButton}
>
{value}
</button>;
};

Comment thread .eslintrc.json
Comment on lines +14 to +15
"plugin:react-hooks/recommended"
// "plugin:testing-library/react"
Copy link
Copy Markdown

@audreyandoy audreyandoy Jan 12, 2022

Choose a reason for hiding this comment

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

I assume jest was removed from VS Code because it was running tests with every change right?

We actually turn off auto run by adding the key-value pair to our settings.json in VS Code:

"jest.autoRun": "off"

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