- React Router Quick Start Guide
- Sagar Ganatra
- 135字
- 2021-07-23 16:41:34
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.
推薦閱讀
- UI圖標創意設計
- JavaScript全程指南
- R語言經典實例(原書第2版)
- Mastering Adobe Captivate 2017(Fourth Edition)
- ASP.NET MVC4框架揭秘
- BeagleBone Media Center
- C語言程序設計
- Python編程:從入門到實踐
- Python Data Analysis Cookbook
- Java編程的邏輯
- Learning Modular Java Programming
- Fast Data Processing with Spark(Second Edition)
- Geospatial Development By Example with Python
- 代替VBA!用Python輕松實現Excel編程
- Java Web從入門到精通(第3版)