[React Router v4] Render Multiple Components for the Same Route
React Router v4 allows us to render Routes as components wherever we like in our components. This can provide some interesting use cases for creating dynamic routes on our applications.
import React from 'react';
import {
BrowserRouter as Router,
Route,
Link
} from 'react-router-dom'; const Links = () =>
<nav>
<Link to="/home">Home</Link>
<Link to="/about">About</Link>
</nav> const Header = ({match}) => (
<div className="header">
<Route path="/:page"
render={({match}) => (
<h1>{match.params.page} header</h1>)} />
</div>
) const Content = ({match}) => (
<div className="content">
<Route path="/:page"
render={({match}) => (
<p>{match.params.page} content</p>)} />
</div>
) const App = (props) => (
<Router basename={props.path}>
<div>
<Links />
<Header />
<Content />
</div>
</Router>
) export default App
[React Router v4] Render Multiple Components for the Same Route的更多相关文章
- [React Router v4] Render Nested Routes
With React Router v4 the entire library is built as a series of React components. That means that cr ...
- [React Router v4] Render Catch-All Routes with the Switch Component
There are many cases where we will need a catch-all route in our web applications. This can include ...
- [React Router v4] Conditionally Render a Route with the Switch Component
We often want to render a Route conditionally within our application. In React Router v4, the Route ...
- [Web 前端] React Router v4 入坑指南
cp from : https://www.jianshu.com/p/6a45e2dfc9d9 万恶的根源 距离React Router v4 正式发布也已经过去三个月了,这周把一个React的架子 ...
- [React Router v4] Intercept Route Changes
If a user has entered some input, or the current Route is in a “dirty” state and we want to confirm ...
- [React Router v4] Redirect to Another Page
Overriding a browser's current location without breaking the back button or causing an infinite redi ...
- [React Router v4] Parse Query Parameters
React Router v4 ignores query parameters entirely. That means that it is up to you to parse them so ...
- React Router V4发布
React Router V4 正式版发布,该版本相较于前面三个版本有根本性变化,遵循 Just Component 的 API 设计理念. 本次升级的主要变更有: 声明式 Declarative 可 ...
- [React Router v4] Use Regular Expressions with Routes
We can use regular expressions to more precisely define the paths to our routes in React Router v4. ...
随机推荐
- IIS发布asp.net mvc项目(asp.net core也是一样)
因为之前都是利用其他的工具在linux上面进行发布,导致现在忘记了在IIS上面怎么发布,现在就记录下来,以防不时之需吧 第一步: 在vs里面进行项目发布:指定好发布的位置,点击发布就好了 第二步:右击 ...
- sql server try catch
一直不习惯Sql Server 2000提供的错误处理机制----繁琐,别扭...如今,Sql Server 2005提供了对Try...Catch的支持,我们总算可以象写程序一样写SQL语句了:) ...
- 【Educational Codeforces Round 35 C】Two Cakes
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 直觉题. 感觉情况会很少. 毕竟间隔太大了.中间肯定有一些数字达不到. 有1肯定可以 2 2 x肯定可以 3 3 3也可以 2 4 ...
- C++面试必备,概念解析
1.C和C++中struct有什么差别? 1> C++中的struct类似于class,有变量.有构造函数.虚函数等.有继承,多态等类的特征: 2> C中的struct仅仅有变量,不能有函 ...
- Xcode7 的两个小坑
Xcode7 还在 beta.时不时崩一下什么的倒也是预料之中的事.没料到的是之前用着好好的,今天升完 El Capitan 之后,模拟器竟然不见了,设备倒是在 schema 栏右边里能看到.只是注明 ...
- BPX-tree
写的匆忙 估计有BUG 修改后 会去掉这个 说明 /** * @author shuly * @date 2017/6/5. */ // hint 一日为叶,终身为叶, 最后还是要转换成 <链 ...
- body{display:none}
body{display:none} 使浏览器不显示内容,用这样的代码删除 $document = str_replace('body{display:none}','',$document);
- 1.3 Quick Start中 Step 2: Start the server官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 2: Start the server Step : 启动服务 Kafka ...
- Myeclipse的默认工作区间怎么恢复提示框?
好久一直使用默认工作空间.现在,回过头来想让那个提示框回来. 该如何做呢? 1.找到我们的myeclipse安装目录下的 2.false是关闭. 3.改成true 4.同时,新增新的工作区间和之前旧的 ...
- programming+windows+MFC
1)CMyApp declares no data members 2)CWinApp::InitInstance run after application build but before the ...