From 4109f7f608a0479fc3e99609d5a02cfd56af3012 Mon Sep 17 00:00:00 2001 From: Davi de Medeiros Date: Tue, 20 Dec 2022 15:15:51 -0300 Subject: [PATCH] rename props --- src/components/Challenge/Challenge.tsx | 10 +++++----- src/components/GameOver/GameOver.tsx | 6 +++--- src/views/App/App.tsx | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/Challenge/Challenge.tsx b/src/components/Challenge/Challenge.tsx index 94e3498..522e36e 100644 --- a/src/components/Challenge/Challenge.tsx +++ b/src/components/Challenge/Challenge.tsx @@ -7,14 +7,14 @@ import { useChallenge } from './useChallenge'; import './Challenge.css'; type Props = { - disabled: boolean; + isGameOver: boolean; onHit: () => void; onMiss: () => void; - onGameOver: () => void; + onTryAgain: () => void; score: number; }; -function Challenge({ disabled, onHit, onMiss, onGameOver, score }: Props) { +function Challenge({ isGameOver, onHit, onMiss, onTryAgain, score }: Props) { const { loading, error, value: challenge } = useChallenge(); async function handleAnswer(answer: string): Promise { @@ -50,10 +50,10 @@ function Challenge({ disabled, onHit, onMiss, onGameOver, score }: Props) { ); } - if (disabled) { + if (isGameOver) { return (
- +
); } diff --git a/src/components/GameOver/GameOver.tsx b/src/components/GameOver/GameOver.tsx index 61db1c0..c78cc84 100644 --- a/src/components/GameOver/GameOver.tsx +++ b/src/components/GameOver/GameOver.tsx @@ -1,11 +1,11 @@ import './GameOver.css'; type Props = { - onGameOver: () => void; + onTryAgain: () => void; score: number; }; -function GameOver({ onGameOver, score }: Props) { +function GameOver({ onTryAgain, score }: Props) { const compliment = score > 0 ? 'Congratulations' : 'Pity'; const needsPlural = score === 0 || score > 1; @@ -15,7 +15,7 @@ function GameOver({ onGameOver, score }: Props) {

{compliment}, you made {score} point{needsPlural ? 's' : ''}!

- diff --git a/src/views/App/App.tsx b/src/views/App/App.tsx index a4b378d..b711e08 100644 --- a/src/views/App/App.tsx +++ b/src/views/App/App.tsx @@ -24,7 +24,7 @@ function App() { setChancesLeft((prev) => prev - 1); } - function handleGameOver(): void { + function handleTryAgain(): void { setScore(INITIAL_SCORE); setChancesLeft(INITIAL_CHANCES_LEFT); } @@ -34,16 +34,16 @@ function App() { document.body.dataset.theme = theme === 'light' ? 'dark' : 'light'; } - const disabled = chancesLeft === 0; + const isGameOver = chancesLeft === 0; return (