- React Router Quick Start Guide
- Sagar Ganatra
- 255字
- 2021-07-23 16:41:34
Inline rendering with the children prop
The children prop should be used in a case where you want to render the view irrespective of whether or not there's a path match. The syntax for the children prop is similar to the render prop, as shown here:
<Route
path="/sidenav"
children={() => (
<div> Inside Sidenav route </div>
)}
/>
The <Route> component with a children prop is rendered even if the path prop is not specified. Also, the exact and strict props will not have any effect on a <Route> component with a children prop.
A <Route> component with a children prop is rendered based on its position in the list of routes. For example, if the previous <Route> component is specified as the last entry in the list of routes, then it is rendered after all the preceding matching routes have been rendered. Also, if the previous <Route> component is listed before the matching route, then the route's content is rendered before rendering the matching route's content, as seen here:
<Route
path="/sidenav"
children={() => (
<div> Inside Sidenav route </div>
)}
/>
<Route
path="/user"
render={() => (
<div> Inside User route </div>
)}
/>
Here, when you try to access the '/user' path, the <Route> component with a children prop is rendered before rendering the route with the '/user' path.
- Learning Java Functional Programming
- Building Modern Web Applications Using Angular
- What's New in TensorFlow 2.0
- Visual Basic編程:從基礎到實踐(第2版)
- Hands-On Data Structures and Algorithms with JavaScript
- HTML5 移動Web開發從入門到精通(微課精編版)
- C#程序設計
- Android玩家必備
- TypeScript圖形渲染實戰:2D架構設計與實現
- 基于JavaScript的WebGIS開發
- Getting Started with Windows Server Security
- Moodle 3.x Developer's Guide
- 川哥教你Spring Boot 2實戰
- Scala編程(第4版)
- TensorFlow.NET實戰