title: react create dynamic tree recursively
body: <p>thanks for reading and helping. Here is my situation so far:</p>
  
  <ol>
  <li><p>I have much data in database, each piece of data has id, parentid(which means you can find the id of its parent using this parentid ), name, description. </p></li>
  <li><p>I want to create a dynamic tree using react,but I do not know how many levels of nodes I have.  Each node represents for an id in database.  An user clicks on a node A on this tree, the children nodes whose parentid equals to A's id will show/hide.</p></li>
  <li><p>I do not intend to retrieve all the data because it will take long time. Now I am able to get one node's children by sending request and get response.body: </p>
  
  <pre><code> getChildren(id){
      ajax.get('http://localhost:8080/configmgmt/code/category/retriveTree/' + id)
     .end((error, response) =&gt; {
     if (!error &amp;&amp; response) {
     console.dir(response.body );
     this.setState(subdata:response.body});
  
  } else {
     console.log('There was an error fetching from database', error);
      }
     }
   );
  }
  </code></pre></li>
  <li><p>in render part, I wrote: </p>
  
  <pre><code>   {this.state.subdata.map((rb,index)=&gt;{
              return  &lt;li&gt;&lt;div&gt;&lt;a href='##' onClick = {this.getChildren.bind(this,rb.id)}&gt;&lt;em&gt;&lt;/em&gt;&lt;label className="one_title"&gt;{rb.name}&lt;/label&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;})
      }
  </code></pre></li>
  </ol>
  
  <p>Here comes the question, I still do not know how to create the tree recursively(because any node might has its children nodes ). how to do this when we can only get a node's children nodes from the database? </p>