title: Dynamic Role Based Routing (React-Router)
body: <p>I am building an e-commerce related product and there are two types of users (customer &amp; seller). Both types of user have their own homepage (totally different to each other). Now I want to route / on customer homepage if customer is logged-in or to seller homepage if seller account is logged-in. Otherwise it should route to landing page. How can I achieve this feature using <code>react-router</code> and <a href="https://github.com/react-boilerplate/react-boilerplate" rel="nofollow noreferrer">this boilerplate</a>?</p>
  
  <p>I tried to do something as follows (but it didn't work):</p>
  
  <pre><code>{
        path: '/',
        name: 'home',
        getComponent(nextState, cb) {
          let HomePagePath = 'containers/HomePage';
          if (customerLoggedIn) {
              HomePagePath = 'containers/CustomerHomePage';
         }
          const importModules = Promise.all([
            import(HomePagePath),
          ]);
  
          const renderRoute = loadModule(cb);
  
          importModules.then(([component]) =&gt; {
            renderRoute(component);
          });
  
          importModules.catch(errorLoading);
        },
      }, 
  </code></pre>