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

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.

主站蜘蛛池模板: 若尔盖县| 榕江县| 泽州县| 贵阳市| 靖远县| 通海县| 罗山县| 红安县| 张家界市| 台北县| 台湾省| 苗栗市| 苗栗市| 思茅市| 赣榆县| 诸暨市| 馆陶县| 古交市| 大石桥市| 全南县| 武鸣县| 龙山县| 灌南县| 曲麻莱县| 南漳县| 原阳县| 右玉县| 南江县| 建阳市| 临江市| 西藏| 丹寨县| 德兴市| 普洱| 夏邑县| 江都市| 华阴市| 桦甸市| 肥东县| 吉隆县| 泽州县|