- 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.
推薦閱讀
- Clojure Programming Cookbook
- Learning Java Functional Programming
- Game Programming Using Qt Beginner's Guide
- PaaS程序設(shè)計(jì)
- C# Programming Cookbook
- DevOps Automation Cookbook
- Oracle數(shù)據(jù)庫(kù)從入門到運(yùn)維實(shí)戰(zhàn)
- Python算法從菜鳥到達(dá)人
- 精通Python自動(dòng)化編程
- Visual C++程序設(shè)計(jì)與項(xiàng)目實(shí)踐
- Three.js權(quán)威指南:在網(wǎng)頁(yè)上創(chuàng)建3D圖形和動(dòng)畫的方法與實(shí)踐(原書第4版)
- Learning Redux
- Python全棧開發(fā):數(shù)據(jù)分析
- Mastering Vim
- Java Web 從入門到項(xiàng)目實(shí)踐(超值版)