title: Use a variable as an object key in reducer
body: <p>I'm having trouble constructing an object. I've got a string (called "SKU" for this example) and it's coming through <code>action</code> as <code>action.name</code>.</p>
  
  <p>I have everything available in the reducer function but I need to change the hardcoded <code>SKU</code> to action.name, but obviously that's not possible in JS. I've tried <code>action.name</code>, <code>action['name']</code> and other variations and I'm stuck. </p>
  
  <p>What is the work around? Any help appreciated! Thanks.</p>
  
  <p>Here's some code so you can see what's going on:</p>
  
  <p><em>function that fires when date changes...</em></p>
  
  <pre><code>handleChange(date) {
    this.props.addDate(date, this.props.dashboardName);
  }
  </code></pre>
  
  <p><em>mapDispatch which is connected at the bottom of the component export...</em></p>
  
  <pre><code>const mapDispatchToProps = dispatch =&gt; {
    return {
      addDate: (date, name) =&gt; dispatch({
        type: 'ACTION_DASHBOARD_ADD_DATE',
        date,
        name
      })
    };
  };
  </code></pre>
  
  <p><em>action creator...</em></p>
  
  <pre><code>export function DashboardDate() {
    return {
      type: ACTION_DASHBOARD_ADD_DATE
    };
  }
  </code></pre>
  
  <p><em>case in the switch of the reducer...</em></p>
  
  <pre><code>case ACTION_DASHBOARD_ADD_DATE: {
        var filter = {};
        filter[action.name] = action.date;
        return {
          ...state,
          dashboard: {
            ...state.dashboard,
            // Below SKU needs to be the value of action.name
            SKU: {
              // Below too, action.name
              ...state.dashboard.SKU,
              filter
            }
          }
        };
      }
  </code></pre>