1
votes

In this tutorial, it says:

Next, we’ll have the Board component receive squares and onClick props from the Game component. Since we now have a single click handler in Board for many Squares, we’ll need to pass the location of each Square into the onClick handler to indicate which Square was clicked. Here are the required steps to transform the Board component:

Delete the constructor in Board.

Why delete the constructor when we are extending class?

1

1 Answers

1
votes

The constructor in this case, is needed to set the initial state:

this.state = {
  history: [{
    squares: Array(9).fill(null),
  }],
  xIsNext: true,
};

Since state is being removed from the component entirely (It's now being passed down through props), it's better to omit the constructor entirely, as it will implicitly call the parent constructor, and initialize a blank state.