官术网_书友最值得收藏!

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.

Both the  component and render props take precedence over the  children prop. Also, when either the  component or  render props are mentioned, the view is rendered only if the path matches the requested URL.

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.

主站蜘蛛池模板: 乌什县| 巢湖市| 福泉市| 鹰潭市| 泸西县| 沙田区| 霍林郭勒市| 冷水江市| 鱼台县| 顺平县| 宁波市| 徐水县| 韶山市| 巴楚县| 涟水县| 新安县| 平凉市| 仁寿县| 临海市| 临沭县| 湖南省| 山东| 南靖县| 会理县| 西青区| 永新县| 金溪县| 越西县| 正定县| 怀来县| 镇原县| 台中县| 鄯善县| 丰宁| 贵阳市| 岚皋县| 江安县| 上栗县| 进贤县| 榆树市| 大化|