title: React : Uncaught TypeError: Cannot read property 'i' of undefined
body: <p>I have a problem with my code:</p>
  
  <pre><code>class Albs extends React.Component{
    constructor(props){
      super(props);
      this.state = {
        i: 0,
        anh: this.props.hinhanh[this.state.i]
      };
      var hinhanh = ["1.png", "2.png", "3.png"];
      this.state.i = this.state.i.bind(this);
    }
    nextPic(){
      this.setState({i: this.state.i++});
    }
    backPic(){
      this.setState({i: this.state.i--});
    }
    render(){
      return(
        &lt;div&gt;
          &lt;img src={this.state.anh}/&gt;
          &lt;br/&gt;
          &lt;button onClick={nextPic}&gt;Next&lt;/button&gt;
          &lt;button onClick={backPic}&gt;Back&lt;/button&gt;
        &lt;/div&gt;
      )
    }
  }
  
  ReactDOM.render(
    &lt;Albs/&gt;,
    document.getElementById('root')
  );
  </code></pre>
  
  <p>In console it shows: Uncaught TypeError: Cannot read property 'i' of undefined. Reason please?</p>