title: Cannot read property 'forEach' of undefined in React
body: <p>I have the next code that i want to use to validate private routing:</p>
  
  <pre><code>import React from 'react';
  
  import { Route, Redirect } from 'react-router-dom';
  import routes from '../../routing/routes';
  
  export default function PrivateRoute({ component: Component, ...rest }) {
      // TODO: user verification
      let user = 1;
  
      const authComponentResolver = props =&gt; {
          const authorizedComponent = &lt;Component {...props} /&gt;
          const redirectToAuthComponent = &lt;Redirect to={{ pathname: routes.login.path, state: { from: props.location } }} /&gt;
  
          if (user !== undefined) {
              return authorizedComponent;
          } else {
              return redirectToAuthComponent;
          }
      }
  
      return (
          &lt;Route {...rest} render={authComponentResolver} /&gt;
      );
  }
  </code></pre>
  
  <p>But it throws the next error:</p>
  
  <pre><code>./src/components/auth/private-route.js
  TypeError: Cannot read property 'forEach' of undefined
  </code></pre>
  
  <p>I cant understand why, but the next code works:</p>
  
  <pre><code>import React from 'react';
  
  import { Route, Redirect } from 'react-router-dom';
  import routes from '../../routing/routes';
  
  export default function PrivateRoute(a) {
      // TODO: user verification
      let user = 1;
  
      const authComponentResolver = props =&gt; {
          const authorizedComponent = &lt;a.component {...props} /&gt;
          const redirectToAuthComponent = &lt;Redirect to={{ pathname: routes.login.path, state: { from: props.location } }} /&gt;
  
          if (user !== undefined) {
              return authorizedComponent;
          } else {
              return redirectToAuthComponent;
          }
      }
  
      return (
          &lt;Route {...a} render={authComponentResolver} /&gt;
      );
  }
  </code></pre>
  
  <p>Can someone explain me why first version fails to compile? Both version do the same i think.</p>
  
  <p>Here is the way i call the component:</p>
  
  <pre><code>const DashboardRoutes = () =&gt; (
      &lt;Switch&gt;
          &lt;PrivateRoute exact path={routes.root.path} component={Dashboard} /&gt;
          &lt;PrivateRoute path={routes.dashboard.path} component={Dashboard} /&gt;
  
          &lt;PrivateRoute exact path={routes.persons.path} component={Persons} /&gt;
          &lt;PrivateRoute path={routes.personsNew.path} component={NewPerson} /&gt;
  
          &lt;PrivateRoute exact path={routes.branchOffice.path} component={BranchOffices} /&gt;
          &lt;PrivateRoute path={routes.personsNew.path} component={NewPerson} /&gt;
  
          &lt;PrivateRoute component={Error404} /&gt;
      &lt;/Switch &gt;
  );
  </code></pre>
  
  <p>In the console i have this error:</p>
  
  <pre><code>VM911 main.chunk.js:116 Uncaught Error: Module build failed (from ./node_modules/eslint-loader/dist/cjs.js):
  TypeError: Cannot read property 'forEach' of undefined
      at Linter.parseResults (Users/groupon/Proyectos/Uselessscat/reservas-client/node_modules/eslint-loader/dist/Linter.js:121)
      at Linter.printOutput (Users/groupon/Proyectos/Uselessscat/reservas-client/node_modules/eslint-loader/dist/Linter.js:85)
      at cache (Users/groupon/Proyectos/Uselessscat/reservas-client/node_modules/eslint-loader/dist/cacheLoader.js:46)
      at Users/groupon/Proyectos/Uselessscat/reservas-client/node_modules/loader-fs-cache/index.js:122
      at Gunzip.cb (Users/groupon/Proyectos/Uselessscat/reservas-client/node_modules/loader-fs-cache/index.js:47)
      at Gunzip.zlibBufferOnEnd (zlib.js:131)
      at Gunzip.emit (events.js:203)
      at endReadableNT (_stream_readable.js:1145)
      at process._tickCallback (internal/process/next_tick.js:63)
      at Object../src/components/auth/private-route.js (VM911 main.chunk.js:116)
      at __webpack_require__ (VM909 bundle.js:786)
      at fn (VM909 bundle.js:151)
      at Module../src/routing/module-router.js (VM911 main.chunk.js:1098)
      at __webpack_require__ (VM909 bundle.js:786)
      at fn (VM909 bundle.js:151)
      at Module../src/routing/router.js (VM911 main.chunk.js:1226)
      at __webpack_require__ (VM909 bundle.js:786)
      at fn (VM909 bundle.js:151)
      at Module../src/index.js (VM911 main.chunk.js:787)
      at __webpack_require__ (VM909 bundle.js:786)
      at fn (VM909 bundle.js:151)
      at Object.0 (VM911 main.chunk.js:2552)
      at __webpack_require__ (VM909 bundle.js:786)
      at checkDeferredModules (VM909 bundle.js:46)
      at Array.webpackJsonpCallback [as push] (VM909 bundle.js:33)
      at VM911 main.chunk.js:1
  </code></pre>
  
  <p>but it is indecipherable :(</p>
  
  <p>Thanks.</p>