Here is a strange problem, here is the code:
...
const PrivateRoute = ({status, component: Component, ...rest}) => (
<Route {...rest} render={ props => (
status ?
(<Component {...props}/>) :
(<Redirect to="/login"/>)
)}/>
)
function mapStateToProps(state) {
return {
status: state.user.status
}
export default connect(mapStateToProps)(PrivateRoute)
The error when doing webpack -d -w:
ERROR in ./public/javascripts/src/admin/components/PrivateRoute.jsx
Module build failed: SyntaxError: Unexpected token (4:53)
2 | import { Route, Redirect } from 'react-router-dom'
3 |
> 4 | const PrivateRoute = ({status, component: Component, ...rest}) => (
| ^
5 | <Route {...rest} render={ props => (
6 | status ?
7 | (<Component {...props}/>) :
The code is just follow the tutorial over here. However, the code blow also uses the '...' in Route {...rest}. When I remove the first '...', the second and third doesn't produce the error. Why does that happen?