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

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.

主站蜘蛛池模板: 阜康市| 综艺| 建昌县| 许昌市| 汶上县| 宁阳县| 牙克石市| 海盐县| 平遥县| 甘德县| 自贡市| 钦州市| 昌黎县| 开封县| 鄂伦春自治旗| 张家界市| 黄冈市| 曲沃县| 民乐县| 沁阳市| 外汇| 南部县| 侯马市| 常宁市| 赤峰市| 共和县| 普洱| 翁牛特旗| 蚌埠市| 汨罗市| 嘉义市| 调兵山市| 郎溪县| 广州市| 驻马店市| 望城县| 定南县| 兰考县| 福安市| 新建县| 黄大仙区|