title: Nested list using React
body: <p>I am trying to create nested lists in separate <code>div's</code> using different input data. I am having a problem printing a nested list: <code>List 2</code> here. I printing the <code>name</code> attribute of object and then checking if there are any <code>childNodes</code> print the <code>name</code> attribute of those too, nested that is. Here's the <code>Parent</code> class.</p>
  
  <pre><code>export default class Parent extends Component {
    render() {
      return (
  
      &lt;div&gt;
        &lt;h4&gt;List 1&lt;/h4&gt;
        &lt;ul&gt;
          {this.props.jsonData1.map(item =&gt; {
            return &lt;Child name={item.name}/&gt;
          })}
        &lt;/ul&gt;
      &lt;/div&gt;
  
      &lt;div&gt;
        &lt;h4&gt;List 2&lt;/h4&gt;
        &lt;ul&gt;
          {this.props.jsonData2.map(item1 =&gt; {
            return &lt;Child name={item1.name}/&gt;
           if(item1.childNodes){
             &lt;ul&gt;
             {item1.jsonData2.map(item2=&gt;{
               return &lt;Child name={item2.name}/&gt;
             })}
           }&lt;/ul&gt;
          })}
        &lt;/ul&gt;
      &lt;/div&gt;
      );
    }
  }
  </code></pre>
  
  <p>My <code>Child</code> class is pretty simple. It only returns a single list element.</p>
  
  <pre><code>export default class Child extends Component {
    render() {
      let {name}=this.props;
      return (
        &lt;li&gt;{name}&lt;/li&gt;
      );
    }
  }
  </code></pre>
  
  <p>I would appreciate some guidance about what I am doing wrong here. I am trying to keep the recursion as simple as possible but apparently I am doing it wrong.</p>