title: Passing a variable to the React useCallback hook
body: <p>I'm having a difficult time learning React hooks.</p>
  
  <p>I'm following along on this website, <a href="https://reactjs.org/docs/hooks-reference.html" rel="noreferrer">https://reactjs.org/docs/hooks-reference.html</a></p>
  
  <pre><code>const onGameOver = React.useCallback(
    ({ playerScore, playerHealth, gameId }) =&gt; {
      setPages(player =&gt;
        arrayMove(playerScore, playerHealth, gameId)
      );
      console.log('gameId: ', gameId);
    },
    [player, gameId]
  );
  </code></pre>
  
  <p>I can see the playerScore and the playerHealth, but not gameId.</p>
  
  <p>I put 'gameId' in my dependency array, but it's always 'undefined' in the console.log.</p>
  
  <p>For testing purposes, I'm just giving gameId a dummy ID like this:</p>
  
  <pre><code>const gameId = useState(123);
  </code></pre>
  
  <p>But eventually, I will use it like this:</p>
  
  <pre><code>&lt;GameOverScreen controlId={ControlId} stats={endGameStats} onGameOver=({onGameOver, gameId}) /&gt;
  </code></pre>
  
  <p>What could I be doing wrong?</p>
  
  <p>Thanks</p>