Fix bug breaking redux store shape

This component was mutating objects passed in as props. Those props were
objects from the redux store. Since they are all references to the same
object, mutating them will mutate the redux store, which is bad.

This change creates a clone of the object before mutating it and passing
it along to another component.
import React, { Component, PropTypes } from 'react';
import { questionProps } from "../prop-types/question_props";
import SearchResult from './SearchResult';

class FormQuestionList extends Component {
  render() {
    if(!this.props.questions){
      return (
        <div>Loading...</div>
      );
    }
    return (
      <div className="question-group">
        {this.props.questions.map((q, i) => {
          let source = Object.assign({}, q);
          source.responseSets = [this.props.responseSets[i]];
          return <SearchResult key={i} type='question' result={{Source: source}} currentUser={{id: -1}} />;
        })}
      </div>
    );
  }
}

FormQuestionList.propTypes = {
  questions: PropTypes.arrayOf(questionProps),
  responseSets: PropTypes.array
};

export default FormQuestionList;

import React, { Component, PropTypes } from 'react';
import { questionProps } from "../prop-types/question_props";
import SearchResult from './SearchResult';

class FormQuestionList extends Component {
  render() {
    if(!this.props.questions){
      return (
        <div>Loading...</div>
      );
    }
    return (
      <div className="question-group">
        {this.props.questions.map((q, i) => {
          let source = q;
          source.responseSets = [this.props.responseSets[i]];
          return <SearchResult key={i} type='question' result={{Source: source}} currentUser={{id: -1}} />;
        })}
      </div>
    );
  }
}

FormQuestionList.propTypes = {
  questions: PropTypes.arrayOf(questionProps),
  responseSets: PropTypes.array
};

export default FormQuestionList;
