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

Inline rendering with the render prop

We have already taken a look at how the component prop can be used to render a view when the <Route> path matches the browser's location.pathname. There are two other props available to render a view: render and children.

The render prop is used for inline rendering. The function mentioned as a value to the render prop should return a React element similar to the following:

<Route
path="/user"
render={() => (
<div> Inside User Route </div>
)}
/>

From the preceding code snippet, when the '/user' path matches the browser's URL, the function specified as a value to the render prop is executed, and the React element returned from this function is rendered.

When you specify both component and render props in the same <Route> component, the component prop will take precedence.

主站蜘蛛池模板: 兰溪市| 昌乐县| 稷山县| 湄潭县| 太和县| 天门市| 加查县| 灵寿县| 玉溪市| 潜山县| 开江县| 隆化县| 沧源| 尚义县| 怀安县| 富阳市| 香港 | 称多县| 高安市| 仙游县| 济宁市| 安岳县| 金阳县| 班玛县| 桃江县| 天全县| 龙胜| 南充市| 民和| 哈巴河县| 富顺县| 宁武县| 洪泽县| 巩留县| 广水市| 彭山县| 清涧县| 九江县| 巫山县| 肥城市| 浠水县|