removeFieldFromMetadata = (state, namePrefix, key) => {
  let tmpState = cloneDeep(state);
  let field = eval(`tmpState.${namePrefix}`);
  if (field === undefined) return tmpState.metadata;
  if (_.isArray(field)) {
    if (key >= field.length) {
      return tmpState.metadata;
    }
    field.splice(key, 1);
  } else {
    if (!_.has(field, key)) {
      return tmpState.metadata;
    }
    delete field[key];
  }
  return tmpState.metadata;
}
Returns the metadata of the state with the removed key. If the field does not
exist, returns the original metadata. Does not mutate the given state.
@param {Object} state
@param {String} namePrefix
@param {String} key
@return {Object} metadata