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

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.

主站蜘蛛池模板: 孟连| 高碑店市| 伽师县| 泌阳县| 合水县| 南昌市| 开封市| 怀化市| 舞阳县| 柳林县| 香格里拉县| 扶风县| 邯郸市| 白朗县| 攀枝花市| 温州市| 江北区| 广安市| 海宁市| 南昌县| 逊克县| 绍兴县| 清水河县| 呼玛县| 金坛市| 玉门市| 建始县| 兴山县| 芷江| 庄河市| 长葛市| 黄浦区| 葫芦岛市| 灵璧县| 大港区| 买车| 拜泉县| 长岭县| 高碑店市| 泾阳县| 河池市|