I'm following this tutorial https://serverless-stack.com/ and am on https://serverless-stack.com/chapters/create-a-route-that-redirects.html
This introduces an AuthenticatedRoute
which checks the value of a prop called isAuthenticated
to decide weather or not to render the component or redirect the user to login
import React from "react";
import { Route, Redirect } from "react-router-dom";
export default ({ component: C, props: cProps, ...rest }) =>
<Route
{...rest}
render={props =>
cProps.isAuthenticated
? <C {...props} {...cProps} />
: <Redirect
to={`/login?redirect=${props.location.pathname}${props.location
.search}`}
/>}
/>;
I get what it achieves, but I'm unsure as to how it's doing it.
Can someone explain to me what's going on with the following bits please?
component: C
...rest
<C {...props} {...cProps} />