title: React: storing components in an object
body: <p>I have a few dozen fields in my users' profiles, and I'm trying to build an efficient means of displaying them in the appropriate input form components. </p>
  
  <p>eg, a profile might look like: </p>
  
  <pre><code>profile1={
    name: 'Cornelius Talmadge',
    phone: '1'
  }
  </code></pre>
  
  <p>And if I could stack components in something like this...</p>
  
  <pre><code>export const FieldCatalogue = {
    name: &lt;TextField defaultValue={this.state.userProfile.name} label={"Name"} /&gt;
  }
  </code></pre>
  
  <p>...then I could do something like this:</p>
  
  <pre><code>for (let field in Object.keys(profile1)) {
    return FieldCatalogue[field]
  }
  </code></pre>
  
  <p>which would be super cool. </p>
  
  <p><a href="https://stackoverflow.com/questions/30762734/multiple-react-components-in-a-single-module">This question</a> has a great answer for if my input components were all constructed via the normal syntax (eg, <code>Component = React.createClass({..})</code>), but:</p>
  
  <p>a. that's a lot of boilerplate</p>
  
  <p>b. i'd have to pass props galore to each one, which isn't optimal</p>
  
  <p>The perfect situation for me would basically be passing input components almost as strings, such that they fell into the scope (state, props, etc.) of whatever parent component they were rendered. </p>
  
  <p>Is this possible and/or advisable?</p>