title: React: onChange is not a function
body: <p>Am new to react and am trying to run unit test for a react app using jest, </p>
  
  <p>The app using the Flux pattern and I have already wrote one component "WEATHER" and before move on to another one I wanted to write test for that component and take TDD approach. </p>
  
  <p>My code running fine but the test fail with this error</p>
  
  <pre><code>TypeError: tree.props.onChange is not a function
  </code></pre>
  
  <p>The weather component code :</p>
  
  <pre><code>// @flow
  
  import React from 'react';
  import api from '../api';
  import weatherStore from '../stores/weatherStore';
  
  //read from weather store
  let _getState = () =&gt; {
      return {weather: weatherStore.returnWeather()};
  };
  
  export default class Weather extends React.Component {
  
  
  
      constructor(proporties) {
          super(proporties);
  
          this._onChange = this._onChange.bind(this);
  
          this.state = _getState();
  
      }
     componentWillUnmount() {
         weatherStore.removeListener('change', this._onChange);
     }
      componentDidMount() {
          api.getWeather();
          weatherStore.on('change', this._onChange);
      }
  
      _onChange() {
          this.setState(_getState());
      } 
  
      render() {
          let weatherState = this.state.weather.map(weather =&gt; {
  
              return &lt;div key={weather.id} className="pull-right row"&gt;
  
                          &lt;div&gt;
                              &lt;span&gt;{weather.main.temp} C&lt;/span&gt;&lt;br /&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;;
          })
  
          return &lt;div&gt;{weatherState}&lt;/div&gt;;
      }
  }
  </code></pre>
  
  <p>Where the test code:</p>
  
  <pre><code>import React from 'react';
  import Weather from '../js/components/Weather';
  import renderer from 'react-test-renderer';
  
  it('should render weather temp and city', ()=&gt; {
      const component = renderer.create(
          &lt;Weather /&gt;
      );
  
      let tree = component.toJSON();
      expect(tree).toMatchSnapshot();
  
      // manually trigger the callback
      tree.props._onChange();
      // re-rendering
      tree = component.toJSON();
      expect(tree).toMatchSnapshot();
  
  });
  </code></pre>
  
  <p>Note since am using flow static type checker it always high light this line of code  <code>this._onChange = this._onChange.bind(this);</code> </p>
  
  <p>with error message saying : property '_onChange' property not found in the weather.</p>