- 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.
推薦閱讀
- Advanced Machine Learning with Python
- Spring Cloud Alibaba微服務架構設計與開發實戰
- Building a Game with Unity and Blender
- 程序員面試算法寶典
- Java程序員面試算法寶典
- MATLAB實用教程
- C語言程序設計實踐教程
- Nexus規模化Scrum框架
- SSM輕量級框架應用實戰
- SQL經典實例(第2版)
- HTML5與CSS3基礎教程(第8版)
- Raspberry Pi Home Automation with Arduino(Second Edition)
- Julia高性能科學計算(第2版)
- 速學Python:程序設計從入門到進階
- C++ System Programming Cookbook