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.
0 Comments
Leave a Reply. |