0
// PrivateRoute.js

const PrivateRoute = props => {
  const { user } = useContext(AuthContext);
  
  let { as: Comp, ...props } = props;
  return user ? <Comp {...props} /> : <Login />;
}

What does the syntax let = { as:comp, ...props } = props; mean? I'm aware of destructuring assignment I just need an english translation.

Devventure
  • 11
  • 1
  • 3
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment – jonrsharpe Oct 22 '20 at 00:26
  • It's assigning the `as` property of `props` to the variable `Comp` and the rest of the `props` properties to `props` – Phil Oct 22 '20 at 00:35

0 Answers0