

The Board component defined that function directly in the JSX.

The Square component received that function as its onSquareClick prop from the Board. Clicking on the upper left square runs the function that the button received as its onClick prop from the Square.Let’s recap what happens when a user clicks the top left square on your board to add an X to it: Keeping the state of all squares in the Board component will allow it to determine the winner in the future. When the Board’s state changes, both the Board component and every child Square re-renders automatically. When clicking on a Square, the child Square component now asks the parent Board component to update the state of the board.

Now that your state handling is in the Board component, the parent Board component passes props to the child Square components so that they can be displayed correctly.
