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

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.

主站蜘蛛池模板: 普宁市| 嵊泗县| 潢川县| 鄂州市| 栾川县| 汶川县| 盘锦市| 珠海市| 正镶白旗| 樟树市| 浮梁县| 新余市| 景泰县| 南召县| 清水县| 叶城县| 遵义市| 富顺县| 临邑县| 衡阳县| 黎平县| 南岸区| 平安县| 沁水县| 平昌县| 刚察县| 靖远县| 长宁区| 吴川市| 剑阁县| 金华市| 屏南县| 连平县| 永福县| 灵山县| 延庆县| 新安县| 涿鹿县| 友谊县| 上栗县| 高淳县|