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

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.

主站蜘蛛池模板: 正阳县| 东兰县| 三明市| 鹤峰县| 黑龙江省| 隆林| 普定县| 黄石市| 新竹县| 邵武市| 乐业县| 朝阳县| 永川市| 长春市| 南乐县| 塘沽区| 昆明市| 嘉鱼县| 武川县| 合江县| 定结县| 余姚市| 江陵县| 庆元县| 临夏市| 通州区| 辛集市| 五家渠市| 安国市| 广平县| 哈密市| 洛南县| 翁牛特旗| 普定县| 潼南县| 濮阳县| 广西| 浮山县| 顺义区| 湖南省| 盐城市|