title: React/Redux - save select value onChange
body: <p>I've created a Component that lets you Add/Remove a dropdown fields (onClick of two buttons). I'm using Redux to keep the state of the dropdown so that when I navigate back and forth (React Router) the added dropdowns are not lost.</p>
  
  <p>Now I also need to keep the values of each dropdown onChange. So onChange I'm sending the value of the dropdowns to the reducer but it seems to be updating all the dropdowns at once (not individually). </p>
  
  <p>Any idea how to fix this?</p>
  
  <p>Here is my code so far:</p>
  
  <p><strong>Component</strong></p>
  
  <pre><code>import React from 'react'
  import { connect } from 'react-redux'
  import uuidV4 from 'uuid-v4'
  import { saveSelect, removeSelect, saveSelectValue, incrementCounter, decrementCounter } from '../actions.js'
  
  
  class AccountUpgrade extends React.Component {
    constructor(props) {
      super(props);
    }
  
    addInput = (counter) =&gt; {
      this.props.saveSelect(uuidV4())
      this.props.incrementCounter(counter)
    }
  
    removeInput = (index, counter) =&gt; {
      this.props.removeSelect(index)
      this.props.decrementCounter(counter)
    }
  
    saveSelectValue = (e) =&gt; {
      let data = {}
      data = e.target.value
  
      this.props.saveSelectValue(data)
    }
  
    renderSelect = (id, index) =&gt; {
      const selectedValue = this.props.selectedValue || ''
      const counter = this.props.counter
  
      return(
        &lt;div className="col-12"&gt;
          &lt;select
            key={id}
            name={'document-'+ id}
            value={selectedValue}
            onChange = {this.saveSelectValue}
          &gt;
            &lt;option value="0"&gt;Please Select&lt;/option&gt;
            &lt;option value="1"&gt;Australia&lt;/option&gt;
            &lt;option value="2"&gt;France&lt;/option&gt;
            &lt;option value="3"&gt;United Kingdom&lt;/option&gt;
            &lt;option value="4"&gt;United States&lt;/option&gt;
          &lt;/select&gt;
  
          &lt;button onClick={ () =&gt; {this.removeInput(index, counter) }}&gt;Remove&lt;/button&gt;
        &lt;/div&gt;
      )
    }
  
    render(){
      const ids = this.props.ids || []
      const counter = this.props.counter
  
      return (
        &lt;div&gt;
  
          {this.props.counter &lt;= 4 &amp;&amp;
            &lt;button onClick={ this.addInput }&gt;Add&lt;/button&gt;
          }
  
          &lt;div className="inputs"&gt;
            {ids.map(this.renderSelect)}
          &lt;/div&gt;
        &lt;/div&gt;
      )
    }
  }
  
  const mapStateToProps = (state) =&gt; {
    return {
      store: state.EligibleAbout,
      ids: state.EligibleAbout.ids,
      selectedValue: state.EligibleAbout.selectedValue,
      counter: state.EligibleAbout.counter,
    }
  }
  
  const EligibleAbout = connect(mapStateToProps, {saveSelect, removeSelect, saveSelectValue, incrementCounter, decrementCounter})(AccountUpgrade)
  
  export default EligibleAbout
  </code></pre>
  
  <p><strong>action.js</strong></p>
  
  <pre><code>export const ADD_SELECT = 'ADD_SELECT'
  export const REMOVE_SELECT = 'REMOVE_SELECT'
  export const SAVE_SELECT_OPTION = 'SAVE_SELECT_OPTION'
  export const INCREMENT_COUNTER = 'INCREMENT_COUNTER'
  export const DECREMENT_COUNTER = 'DECREMENT_COUNTER'
  
  export function saveSelect(data) {
    return { type: ADD_SELECT, data }
  }
  
  export function removeSelect(data) {
    return { type: REMOVE_SELECT, data }
  }
  
  export function saveSelectValue(data) {
    return { type: SAVE_SELECT_OPTION, data}
  }
  
  export function incrementCounter(data) {
      return { type: INCREMENT_COUNTER, data }
  }
  
  export function decrementCounter(data) {
      return { type: DECREMENT_COUNTER, data }
  }
  </code></pre>
  
  <p><strong>reducer.js</strong></p>
  
  <pre><code>import { combineReducers } from 'redux'
  import { ADD_SELECT, REMOVE_SELECT, SAVE_SELECT_OPTION } from './actions'
  
  function EligibleAbout(state = { ids: [], counter: 0, selectedValue: 'Please select'}, action = {}){
    switch (action.type){
      case ADD_SELECT:
        return {
          ...state,
          ids: [].concat(state.ids, action.data),
        }
      case REMOVE_SELECT:
        return {
          ...state,
          ids: state.ids.filter((id, index) =&gt; (index !== action.data)),
        }
      case SAVE_SELECT_OPTION:
        return {
          ...state,
          selectedValue: action.data
        }
      case INCREMENT_COUNTER:
        return {
          ...state,
          counter: state.counter + 1
        }
      case DECREMENT_COUNTER:
        return {
          ...state,
          counter: state.counter - 1
        }
      default:
        return state
    }
  }
  
  const FormApp = combineReducers({
    EligibleAbout
  })
  
  export default FormApp
  </code></pre>