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

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.

主站蜘蛛池模板: 余江县| 邹城市| 罗田县| 通城县| 濉溪县| 临漳县| 黄陵县| 曲松县| 化州市| 白银市| 朝阳市| 墨竹工卡县| 射阳县| 海南省| 汝南县| 滁州市| 太白县| 卢龙县| 杂多县| 胶南市| 鸡西市| 额济纳旗| 绥中县| SHOW| 扎兰屯市| 岳阳市| 比如县| 罗源县| 进贤县| 仁怀市| 通辽市| 桐乡市| 满洲里市| 三穗县| 麦盖提县| 唐海县| 祁连县| 昭通市| 景宁| 巴南区| 和平县|