- 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.
- Spring 5.0 Microservices(Second Edition)
- C和C++安全編碼(原書第2版)
- Learning Linux Binary Analysis
- Python高效開發實戰:Django、Tornado、Flask、Twisted(第2版)
- Hands-On Nuxt.js Web Development
- 深度實踐KVM:核心技術、管理運維、性能優化與項目實施
- Learn Linux Quickly
- Java EE 7 Development with WildFly
- 城市信息模型平臺頂層設計與實踐
- Python機器學習
- Python深度學習入門:從零構建CNN和RNN
- VBA Automation for Excel 2019 Cookbook
- C++ Game Development Cookbook
- VB語言程序設計教程(第2版)
- Unity Certified Programmer:Exam Guide