React.createElement: type is invalid expected a string or a class/function but got: <div />

Keywords: reactjs

Question: 

Error: React.createElement: type is invalid expected a string or a class/function but got: . Did you accidentally export a JSX literal instead of a component?

class TestDynamic extends React.Component {

  getSpan(value) {
    return (<span>Spanned {value}</span>)
  }

  renderDynamicComponent() {
    const Test = this.getSpan(1)
    return (<div> <Test />  </span>)
  }

  render() {
    return (<div>{this.renderDynamicComponent() }</span>)
  }

}

I tried with return (<div>{ Test }</span>) it displays nothing

Answers: 

Instead of declaring Test as a plain class, extend it from React.Component and render it like <Test />. Also render getSpan as {Test1}

class Test extends React.Component{

  getSpan(value) {
    return (<span>Spanned {value}</span>)
  }

  renderDynamicComponent() {
    const Test1 = this.getSpan(1)
    return (<div> {Test1}</div>)
  }

  render() {
    return (<div>{this.renderDynamicComponent() }</span>)
  }

}