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

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.

主站蜘蛛池模板: 肇源县| 县级市| 自治县| 新沂市| 大城县| 桃源县| 南宫市| 佛冈县| 沾化县| 新巴尔虎右旗| 延川县| 昌宁县| 富顺县| 建德市| 渝北区| 鄄城县| 炉霍县| 鄂尔多斯市| 屏东县| 镇巴县| 濮阳市| 仪征市| 莒南县| 阿拉善盟| 墨竹工卡县| 成武县| 长沙县| 辉县市| 巴彦淖尔市| 井研县| 庄浪县| 河间市| 凤山市| 柯坪县| 行唐县| 贵定县| 吴忠市| 南涧| 娱乐| 广丰县| 临湘市|