Cannot read property 'stateChanges' of undefined code example

Example 1: Cannot read property 'valueChanges' of undefined

this.yourFormGroup.get('controlName').valueChanges.subscribe(() => {
	//Executed code when is detected a change on the 'controlName'
});

Example 2: TypeError: Cannot read property 'setState' of undefined

class Counter extends React.Component {
    constructor(props) {
      super(props);

      this.state = {
          count : 1
      };

      this.delta = this.delta.bind(this);
	}

    delta() {
        this.setState({
            count : this.state.count++
        });
    }

    render() {
        return (
            <div>
                <h1>{this.state.count}</h1>
                <button onClick={this.delta}>+</button>
            </div>
        );
    }
}

Example 3: Cannot read property 'setState' of undefined

//  way #1 - recommended
// puting .bind(this) after using the reference 

	<input onChange={this.onInputChange.bind(this)} placeholder="First Name" />
  
// way #2
// adding this line for each method you use
  
  constructor(){
	this.onInputChange = this.onInputChange.bind(this)
  }