title: React State listen for Object Attribute Change
body: <p>One of my components instantiates a class and stores it in the state. The Person class is used in many components.</p>
  
  <pre><code>// Car class
  this.state = {
      driver: new Person(),
      passenger: new Person()
  }
  </code></pre>
  
  <p>It then displays the location of the person</p>
  
  <pre><code>// Car class
  render() {
      return (
          &lt;div&gt;
              &lt;img src={this.state.driver.src} style={{left: this.state.driver.x, top: this.state.driver.y}} /&gt;
              &lt;img src={this.state.passenger.src} style={{left: this.state.passenger.x, top: this.state.passenger.y}} /&gt;
              &lt;span onClick={this.state.driver.moveRight}&gt;Move Driver&lt;/span&gt;
              &lt;span onClick={this.state.passenger.moveRight}&gt;Move Passenger&lt;/span&gt;
          &lt;/div&gt;
      )
  }
  </code></pre>
  
  <p>The moveRight function being</p>
  
  <pre><code>//Person class
  moveRight() {
      this.x += 1;
  }
  </code></pre>
  
  <p>This avoids re-writing the Person.moveRight() method in all the components that need the person to be moved.</p>
  
  <p>However, the state does not update when the car's attributes are updated, is there a way to fix this so the state updates appropriately, or is this not a good way to implement this?</p>