- 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.
- Google Apps Script for Beginners
- MATLAB 2020 從入門到精通
- Building Minecraft Server Modifications
- 碼上行動:用ChatGPT學會Python編程
- Android程序設計基礎
- Building RESTful Python Web Services
- SQL Server與JSP動態網站開發
- C/C++程序員面試指南
- 微信小程序開發實戰:設計·運營·變現(圖解案例版)
- 零基礎學C語言(升級版)
- Mastering JavaScript
- Visual C++程序設計與項目實踐
- KnockoutJS Blueprints
- MATLAB從入門到精通
- Visual Basic程序設計