I have the following React component:
export default function AuthExample () {
return (
<Router>
<div>
<AuthButton/>
<ul>
<li><Link to="/public">Public Page</Link></li>
<li><Link to="/protected">Protected Page</Link></li>
</ul>
<Route path="/public" component={Public} />
<Route path="/login" component={ Login } />
<PrivateRoute path='/protected' component={ Protected } />
</div>
</Router>
)
}
My difficulty is understanding the parameters passed to the component and how it is being unboxed in the function that creates this component , below is the function:
const PrivateRoute = ({ component: Component, ...rest }) => (
<Route {...rest} render={(props) => (
fakeAuth.isAuthenticated === true
? <Component {...props} />
: <Redirect to={{
pathname: '/login',
state: { from: props.location }
}} />
)} />
)
So what exactly is component: Component
here ? and is the ES-5 destructive assignment ? so then what exact is <Component {...props} />
in the end ?