title: How to create a Dynamic Reducer in Redux
body: <p>I have this <code>object</code> in my state from the <em>Redux Store</em>: </p>
  
  <pre><code> altaUsuario: {
      //identificacion
      identificacion : {
        email:  '',
        username: '',      
      },
      //Localización
      localizacion : {     
        direccion: '',
        cp: '', 
        provincia: '',
      },
      //Redes sociales
      rdSocial : [
        { 
          red:"", 
          name:""
        },
      ],
  </code></pre>
  
  <p>Let's say that I have three steps on my form, and each of them updates a specific section, so I call an action for update <em>identification</em> other action for update <em>localizacion</em> and the last one for update <em>rdSocial</em>, (Sorry for the Spanish variables). 
  The important part here is the payload from each action, which is a piece of the entire <code>altaUsuario</code> object, for example, this is one of my actions: </p>
  
  <pre><code>{
    type: 'ADD_ID_FIELDS',
    payload: {
      email: '',
      username: 'josue',
    }
  }
  </code></pre>
  
  <p>Now, my reducer makes a copy from the state object and update the <em>altaUsuario</em> property, with the update of the specific part of the object that I want to update. (It sound confusing) Lets see how I am doing it:</p>
  
  <pre><code>    case ADD_ID_FIELDS: 
        return { ...state, altaUsuario : {...state.altaUsuario, identificacion :action.payload }}
      case ADD_LOCAL_FIELDS: 
        return { ...state, altaUsuario : {...state.altaUsuario, localizacion :action.payload }}
      case ADD_RD_SOCIAL: 
        return { ...state, altaUsuario : { ...state.altaUsuario, rdSocial : action.payload}}
      default:
  </code></pre>
  
  <blockquote>
    <p><strong>So, How could I automate this process in one single action?</strong></p>
  </blockquote>
  
  <p>This is what I have so far, But it doesn't work: </p>
  
  <pre><code>case ADD_FIELD: 
        Object.keys(state.altaUsuario).map (cat =&gt; { 
            if(Object.keys(action.payload).some(r=&gt; Object.keys(state.altaUsuario[cat]).includes(r))){                  
              return { ...state, altaUsuario : {...state.altaUsuario, [cat] :action.payload }}
            }
        })
  </code></pre>
  
  <p>My idea was to make a search inside the <em>altaUsuario</em> with the specific property that I want to update, but it doesn't work. </p>
  
  <p>Is this a good approach?</p>