title: Loop through an array to create routes in react router
body: <p>I want to hit an API which returns me all the routes of the website that I will need for the react website.</p>
  
  <p>I'm not entirely sure on how to do it or even google an example.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>ReactDOM.render(
  &lt;Router history={browserHistory}&gt;
      &lt;Route path="/" component={App}&gt;
        &lt;IndexRoute pageId={5} background="" component={Home}/&gt;
        &lt;Route path="/your-journey" background="" pageId={7} component={YourJourney}/&gt;
        &lt;Route path="/designed-for-you" background="" pageId={6} component={DesignedForYou}/&gt;
        &lt;Route path="/join-us" background="" pageId={1} component={JoinUs}/&gt;
        &lt;Route path="/get-in-touch" background="no-hero-image" pageId={4} component={GetInTouch}/&gt;
        &lt;Route path="/legal-and-compliance" background="no-hero-image" pageId={8} component={Legal}/&gt;
        &lt;Route path="/privacy" background="no-hero-image" pageId={9} component={Privacy}/&gt;
      &lt;/Route&gt;
    &lt;/Router&gt;,
    document.getElementById('root')
  );
  </code></pre>
  
  <p>Where everything under the Route path="/" needs to come from the API.</p>