title: React and using ReactDOM.createPortal() - Target container is not a DOM element Error
body: <p>I'm working on a React app and am trying to use <code>ReactDOM.createPortal()</code> to add html content to a div that is <em>outside</em> the component (called ToDoItem).</p>
  
  <pre><code>{ReactDOM.createPortal(
      &lt;Route path={`/profile/project/${this.props.project._id}`} render={() =&gt; 
      &lt;ProjectView project={this.props.project}/&gt;}  /&gt;,
      document.getElementById('tasks')
  )}
  </code></pre>
  
  <p>None of the HTML in the public folder is predefined - it is all dynamically created. </p>
  
  <p>I think this could be the cause of the error: React tries to add HTML to the div with the id of <code>tasks</code> which, but the div is not loaded into the DOM before this happens?</p>
  
  <p>If this method is incorrect, is there any other method I can use append html content to another div outside the component?</p>
  
  <p>Some other info: the component from which I tried to run this method is a stateless component, not a class component. </p>
  
  <p>This is the error:</p>
  
  <p><a href="https://i.stack.imgur.com/9ByeE.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/9ByeE.jpg" alt="enter image description here"></a></p>