title: React JS Error "...rest" Syntax error: Unexpected token
body: <p>I am new to React and looking at this ReactTraining.  I would like to make some of my paths private (that way you can only view them when you are logged in).  I am able to authenticate users fine and direct them to a new page, but now I would like to "Protect" that page so that it is only accessible after logging in.  I found a few different <a href="https://github.com/ReactTraining/react-router/blob/master/packages/react-router-website/modules/examples/Auth.js" rel="nofollow noreferrer">sources</a> that seem to use the same "PrivateRoute" function below.  Everything seems to work great so far (and makes sense), except for the "...rest" part of this following code:</p>
  
  <pre><code>const PrivateRoute = ({ component: Component, ...rest }) =&gt; (
    &lt;Route {...rest} render={props =&gt; (
      fakeAuth.isAuthenticated ? (
        &lt;Component {...props}/&gt;
      ) : (
        &lt;Redirect to={{
          pathname: '/login',
          state: { from: props.location }
        }}/&gt;
      )
    )}/&gt;
  )
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>Uncaught Error: Cannot find module "./components/Login"
      at webpackMissingModule (router.js:9)
      at Object.&lt;anonymous&gt; (router.js:9)
      at __webpack_require__ (bootstrap 18b9132…:555)
      at fn (bootstrap 18b9132…:86)
      at Object.&lt;anonymous&gt; (index.js:22)
      at __webpack_require__ (bootstrap 18b9132…:555)
      at fn (bootstrap 18b9132…:86)
      at Object.&lt;anonymous&gt; (bootstrap 18b9132…:578)
      at __webpack_require__ (bootstrap 18b9132…:555)
      at bootstrap 18b9132…:578
  webpackMissingModule @ router.js:9
  (anonymous) @ router.js:9
  __webpack_require__ @ bootstrap 18b9132…:555
  fn @ bootstrap 18b9132…:86
  (anonymous) @ index.js:22
  __webpack_require__ @ bootstrap 18b9132…:555
  fn @ bootstrap 18b9132…:86
  (anonymous) @ bootstrap 18b9132…:578
  __webpack_require__ @ bootstrap 18b9132…:555
  (anonymous) @ bootstrap 18b9132…:578
  (anonymous) @ bootstrap 18b9132…:578
  webpackHotDevClient.js:233 Error in ./src/components/Login.js
  Syntax error: Unexpected token (16:46)
  
    14 | 
    15 | 
  &gt; 16 | const PrivateRoute = ({ component: Component, ...rest }) =&gt; (
       |                                               ^
    17 | &lt;Route {...rest} render={props =&gt; (
    18 |   fakeAuth.isAuthenticated ? (
    19 |     &lt;Component {...props}/&gt;
  
   @ ./src/router.js 25:13-42
  </code></pre>
  
  <p>It appears that I am importing everything that I should be so my thought is that I don't have something installed that should be. </p>
  
  <p>Does anyone know what I may need to install to resolve this error?</p>