title: React router error (Failed prop type: Invalid prop `children` supplied to `Switch`, expected a ReactNode.)
body: <p>Try to modify component, the main idea is, I want create login page, try modify App.js but get error</p>
  
  <blockquote>
    <p>warning.js?6327:36 Warning: Failed prop type: Invalid prop <code>children</code>
    supplied to <code>Switch</code>, expected a ReactNode.</p>
  </blockquote>
  
  <p>My code is:</p>
  
  <pre><code>class App extends Component {
    constructor(props) {
        super(props)
  
  
  }
  
   routeWithSubRoutes(route) {
    return (
      &lt;Route
        key={_.uniqueId()}
        exact={route.exact || false}
        path={route.path}
        render={props =&gt; (
          // Pass the sub-routes down to keep nesting
          &lt;route.component {...props} routes={route.routes || null} /&gt;
        )}
      /&gt;
    );
   } 
  
   render () {
    return (
      &lt;div className={styles.App}&gt;
      &lt;Helmet {...config.app} /&gt;
      &lt;NavBar /&gt;
      &lt;Switch&gt;
        {routes.map(route =&gt; this.routeWithSubRoutes.bind(this,route))}
      &lt;/Switch&gt;
      &lt;/div&gt;
    )
   }
  
  
  
  }
  
  export default App;
  </code></pre>
  
  <p>Code that I try to modify</p>
  
  <pre><code>export default () =&gt; {
    // Use it when sub routes are added to any route it'll work
  
    const login = () =&gt; {
  
    }
  
    const routeWithSubRoutes = route =&gt; (
      &lt;Route
        key={_.uniqueId()}
        exact={route.exact || false}
        path={route.path}
        render={props =&gt; (
          // Pass the sub-routes down to keep nesting
          &lt;route.component {...props} routes={route.routes || null} /&gt;
        )}
      /&gt;
    );
  
    var isLogin = false;
  
    if(!isLogin) {
      return (
        &lt;Login /&gt;
      )
    }
  
    if(isLogin) {
      return (
        &lt;div className={styles.App}&gt;
          &lt;Helmet {...config.app} /&gt;
          &lt;NavBar /&gt;
          &lt;Switch&gt;
            {routes.map(route =&gt; routeWithSubRoutes(route))}
          &lt;/Switch&gt;
        &lt;/div&gt;
      );
    }
  
  
  };
  </code></pre>
  
  <p>this code is working, but my not, how to fix this?</p>