将组件作为道具传递给Route与渲染函数中的包装组件之间的区别

问题描述 投票:1回答:1

路由到这样的组件有什么区别:

 <Route path="coolPath" component={MyComponent} />
or
 <Route path="coolPath" render={props => <MyComponent {...props} customProp="s" } />

至此:

 <Route path"=coolPath">
      <MyComponent />
 </Route>
or
 <Route path"=coolPath">
      <MyComponent cusomProps="cp"/>
 </Route>
reactjs routes react-router react-router-v4 react-router-v5
1个回答
1
投票

首先,您应该通读本网站:https://reacttraining.com/react-router/web/api/Route

© www.soinside.com 2019 - 2024. All rights reserved.