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

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.

主站蜘蛛池模板: 山西省| 贡觉县| 株洲县| 定安县| 灌南县| 宝坻区| 临澧县| 克什克腾旗| 普定县| 安陆市| 印江| 临沂市| 甘泉县| 灌南县| 会东县| 清水河县| 翁源县| 维西| 通道| 阆中市| 句容市| 合肥市| 永兴县| 达州市| 建水县| 邻水| 道孚县| 邵东县| 虞城县| 东平县| 江陵县| 南召县| 抚顺市| 英吉沙县| 西丰县| 搜索| 江口县| 应城市| 德惠市| 安西县| 息烽县|