title: Passing Data to Action Creator from Component in Redux
body: <p>I'm trying to change the zoom level by passing a level of 13 into my action creator.</p>
  
  <p>But get this error:</p>
  
  <p>Error: Given action "ZOOM_SELECTED", reducer "zoom" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.</p>
  
  <p>Do you know how to change the current state passing a new zoom level into my action creator?</p>
  
  <pre><code>    render() {
          console.log(this.props.zoom)
          return (
              &lt;div&gt;
                  &lt;Map className='map' center={this.props.mapCenter} zoom={this.props.zoom}&gt;
                      &lt;TileLayer
                      attribution='&amp;amp;copy &lt;a href="http://osm.org/copyright"&gt;OpenStreetMap&lt;/a&gt; contributors'
                      url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
                  /&gt;
                  &lt;Marker position={this.props.mapCenter}&gt;
                      &lt;Popup&gt;
                          A pretty CSS3 popup. &lt;br /&gt; Easily customizable.
            &lt;/Popup&gt;
                  &lt;/Marker&gt;
  
                  &lt;/Map&gt; &lt;button onClick={() =&gt; this.props.selectZoom((13))} &gt;Ändra zoom&lt;/button&gt;
              &lt;/div &gt;
          )
  
      }
  };
  
  const mapStateToProps = (state) =&gt; {
      return {
          zoom: state.zoom,
          mapCenter: state.mapCenterPosition
      }
  };
  
  const mapDispatchToProps = dispatch =&gt; {
      return {
          selectZoom: () =&gt; dispatch(selectZoom())
      }
  }
  
  export default connect(mapStateToProps, mapDispatchToProps)(MapComponent); ```
  
  </code></pre>
  
  <p>Action Creator</p>
  
  <pre><code>
  export const selectZoom = (zoom) =&gt; {
      console.log('action',zoom)
      return {
          type: 'ZOOM_SELECTED',
          payload: zoom
      };
  };
  
  </code></pre>
  
  <p>Reducer</p>
  
  <pre><code>
  const zoomReducer = (state = 8, action) =&gt; {
     if(action.type === 'ZOOM_SELECTED') {
         return action.payload;
     } else {
         return state;
     }
  };
  
  </code></pre>