From the course: Master React 19 and Next.js 16 with Hands-On Projects and Real-World Applications

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

ScoreBoard

ScoreBoard

In this session, we'll enhance our memory matching game by adding a scoreboard. This scoreboard will display the total moves made, the current number of matches, and the total number of pairs. This is a crucial element for any game, providing feedback to the player on their progress. Moving to AppJSX. Now I am adding a call to the Scoreboard component just below the Settings component. At this point, I'm simply placing the component without passing any props. We'll connect it to the Game State in the next step. Let's connect our Scoreboard component to the Game State. I am passing three props to the Scoreboard component – Moves, Matches, and Total. The Moves prop tracks the number of moves the player has made. keeps count of successful matches. And total represents the total number of pairs, calculated as deck.length divided by 2. This ensures the scoreboard displays the correct dynamic data. Moving to scoreboard.jsx. In order to receive the data from app.jsx, I modify the scoreboard…

Contents