title: React Native & Redux : undefined is not an object (evaluating 'state.counter')
body: <p>I was trying to use Redux in my React Native project to create a counter app. But then I encounter this error. It says sth like  <code>undefined is not an object (evaluating 'state.counter')</code></p>
  <p>Please have a look at my code.</p>
  <p>Counter.js</p>
  <pre><code>class Counter extends Component {
    state = {counter: 0};
  
    render() {
      return (
        &lt;View style={styles.container}&gt;
          &lt;View style={styles.counterPart}&gt;
            &lt;TouchableOpacity onPress={() =&gt; this.props.increaseCounter()}&gt;
              &lt;Text style={styles.text}&gt;Increase&lt;/Text&gt;
            &lt;/TouchableOpacity&gt;
            &lt;Text style={styles.text}&gt;{this.props.counter}&lt;/Text&gt;
            &lt;TouchableOpacity onPress={() =&gt; this.props.decreaseCounter()}&gt;
              &lt;Text style={styles.text}&gt;Decrease&lt;/Text&gt;
            &lt;/TouchableOpacity&gt;
          &lt;/View&gt;
        &lt;/View&gt;
      );
    }
  }
  
  function mapStateToProps(state) {
    return {
      counter: state.counter,
    };
  }
  
  function mapDispatchToProps(dispatch) {
    return {
      increaseCounter: () =&gt; dispatch({type: 'INCREASE_COUNTER'}),
      decreaseCounter: () =&gt; dispatch({type: 'DECREASE_COUNTER'}),
    };
  }
  
  export default connect(mapStateToProps, mapDispatchToProps)(Counter);
  </code></pre>
  <p>The error seems to result from <code>mapStateToProps(state)</code> function above.</p>
  <p>App.js</p>
  <pre><code>const reducer = (state = initialState, action) =&gt; {
    switch (action.type) {
      case 'INCREASE_COUNTER':
        console.log('Enter INCREASE_COUNTER reducer');
        return {counter: state.counter + 1};
      case 'DECREASE_COUNTER':
        console.log('Enter DECREASE_COUNTER reducer');
        return {counter: state.counter - 1};
    }
    return state;
  };
  
  const store = createStore(reducer);
  
  const initialState = {
    counter: 0,
  };
  
  class App extends Component {
    render() {
      return (
        &lt;Provider store={store}&gt;
          &lt;Counter /&gt;
        &lt;/Provider&gt;
      );
    }
  }
  </code></pre>
  <p>I would appreciate if you can provide a solution or a suggestion to this issue. Thank you.</p>