State not updating when receiving new props (ReactJS) : <p>I'm new to React. I'm stuck on this, would really appreciate some help! </p>

<p>A parent component will pass an array into this child component. When I console.log(this.props.repairs) it shows me an array of 4. I am trying to update this.state.sortedDataList whenever the array of repairs is passed in. The console.log(this.state) is still showing sortedDataList as an empty array. </p>

<p>What am I doing wrong? Thanks so much, appreciate any help. </p>

<pre><code>class Repairs extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      sortedDataList: []
    };
  }

  componentWillReceiveProps(nextProps) {
    if(this.props != nextProps) {
      this.setState({
        sortedDataList: this.props.repairs
      });
    }
  }

  render() {
    console.log(this.props);
    console.log(this.state);

    return (
      &lt;div&gt;&lt;/div&gt;
    );
  }
}
</code></pre>
