[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. ...
随机推荐
- 如何运行vue项目(维护他人的项目)
假如你是个小白,在公司接手他人的项目,这个时候,该怎么将这个项目跑通? 前提: 首先,这个教程主要针对vue小白,并且不知道安装node.js环境的.言归正传,下面开始教程:在维护项目之前,需要把所有 ...
- 【2017 Multi-University Training Contest - Team 6】Kirinriki
[链接]http://acm.hdu.edu.cn/showproblem.php?pid=6103 [题意] 给出一串字符串,从中选出两个不重叠的字符串,使得两个字符串的距离和 <= m 的最 ...
- 邮件协议与port
电子邮箱的协议有SMTP.POP2.POP3.IMAP4等.都隶属于TCP/IP协议簇,默认状态下.分别通过TCPport25.110和143建立连接.针对不同的用途和功能,我们在邮件se ...
- Delphi部份函数,命令,属性中文说明
Abort 函数 引起放弃的意外处理 Abs 函数 绝对值函数 AddExitProc 函数 将一过程添加到运行时库的结束过程表中 Addr 函数 返回指定对象的地址 AdjustLineBreaks ...
- Apache中PHP5.3 php5.4如何使用ZEND
Apache中PHP5.3 php5.4如何使用ZEND 有一套zend加密程序,需要安装ZEND,经过多次尝试,结果如下 由于PHP有安全线程(TS)和非安全线程(NTS)区分,PHP官方网站上说, ...
- bootstrap课程13 bootstrap的官方文档中有一些控件的使用有bug,如何解决这个问题
bootstrap课程13 bootstrap的官方文档中有一些控件的使用有bug,如何解决这个问题 一.总结 一句话总结:因为演示是正常的,所以检查演示效果的代码,把那一段相关的都弄过来就可以了 ...
- C#string转换为Datetime
DateTime.ParseExact("0710090000", "MMddHHmmss", CultureInfo.CurrentCulture, Date ...
- Linux下读写寄存器
arm裸机下读写寄存器很容易,各个寄存器和内存的地址是单一地址空间,他们是用相同的指令进行读写操作的.而在linux下就要复杂很多,因为linux支持多个体系架构的CPU.比如arm和x86就不一样, ...
- 对DataTable进行过滤筛选的一些方法Select,dataview
当你从数据库里取出一些数据,然后要对数据进行整合,你很容易就会想到: DataTable dt = new DataTable();//假设dt是由"SELECT C1,C2,C3 FROM ...
- 前端面试题(计算机网络/http/https)
(前端面试题大全,持续更新) 输入url的一系列过程 http缓存(缓存生效的情况),拓展下 get与post的异同,POST一般可以发送什么类型的文件 jsonp有什么不好的地方 http请求头(h ...