React router auth工作流示例中的Spread运算符
尝试获取异步身份验证请求(axios)以在react路由器中工作。我已经同步使用react router有一段时间了,我了解渲染函数的变体,但是在auth工作流示例[1]中的这个组件中:React router auth工作流示例中的Spread运算符,react-router,React Router,尝试获取异步身份验证请求(axios)以在react路由器中工作。我已经同步使用react router有一段时间了,我了解渲染函数的变体,但是在auth工作流示例[1]中的这个组件中: const PrivateRoute = ({ component: Component, ...rest }) => ( <Route {...rest} render={props => ( fakeAuth.isAuthenticated ? ( <Comp
const PrivateRoute = ({ component: Component, ...rest }) => (
<Route {...rest} render={props => (
fakeAuth.isAuthenticated ? (
<Component {...props}/>
) : (
<Redirect to={{
pathname: '/login',
state: { from: props.location }
}}/>
)
)}/>
)
const PrivateRoute=({component:component,…rest})=>(
(
伪造的。是否已验证(
) : (
)
)}/>
)
扩展运算符…rest
应该扩展到什么和/或返回什么?我假设它是某种异步/restful调用,但我根本不理解它在上面的Route语句中的位置(第二行)。它应该返回路径吗?承诺?或者简单地以某种方式异步更新身份验证状态(例如,在下一行中设置isAuthenticated
)
感谢对文档的建议和指点
编辑:看起来这只是其他道具的一般列表。我想我想得太多了
[1]