title: How to use some param to get React component
body: <p>I want to according to different param render different views  in a Component , these views from some template.
  <code>Main.js</code></p>
  
  <pre><code>render() {
    const{ data, isEdit } = this.props
    console.log('Detail data:', data)
    console.log('isEdit:', isEdit)
    return &lt;div&gt;
    {getView(data)}
   &lt;/div&gt;
  }
  </code></pre>
  
  <p><code>getView</code></p>
  
  <pre><code>function getView(data) {
    let modelName = getModelName(data.PolciyName)
    modelName = 'M1'
    if (modelName) {
      let Model = require(`./models/${modelName}`)
      console.log('getView- modelName', modelName)
      console.log('typeof', typeof M1) //Object
      return &lt;div&gt;&lt;Model data={data} /&gt;&lt;/div&gt;
      } else {
      return &lt;div&gt;no data&lt;/div&gt;
    }
  }
  </code></pre>
  
  <p><code>M1</code></p>
  
  <pre><code>function M1(data) {
    return &lt;div&gt;
      &lt;h2&gt;{data.name}&lt;/h2&gt;
    &lt;/div&gt;
  }
  </code></pre>
  
  <p>and this code can't work, It will get a error.
  <code>Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of</code>Main<code>.</code></p>