The spread operator basically puts all remaining properties into a new object called rest
in your case. Let's say that PrivateRoute was initiated like this:
<PrivateRoute component={Home} path="/protected" secure={false} />
component
was desctructured and renamed to Component
in your example. This means that rest
looks like this:
rest = {
path: "/protected",
secure: false
}
What happens next is that the rest
object is spreaded into the Route. So this:
<Route {...rest} render={(props) => ()} />
is the same as this:
<Route path={res.path} secure={res.secure} render={(props) => ()} />
or this:
<Route path="/protected" secure={false} render={(props) => ()} />
By the way, the props in the render()
function only contain three props and they come from the Router:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…