[React Router v4] Use the React Router v4 Link Component for Navigation Between Routes
If you’ve created several Routes within your application, you will also want to be able to navigate between them. React Router supplies a Link component that you will use to make this happen.
Import Link:
import {
BrowserRouter as Router,
Route, Link
} from 'react-router-dom';
Add Nav section to the page
const Nav = () => (
<nav>
<Link to="/">Home</Link>
<Link to="/about">About</Link>
<Link replace to={{pathname: '/contact'}}>Contact</Link>
</nav>
);
There are two ways to nav to another page.
1. to="/about"
2. to={{pathname: '/contact'}}
Here the 'replace' keyword able to help modify pushHistory. Once you use 'replace' it will replace previous state to current state, instead of add one state.
For example.
Current history: ['/', '/about', '/contact'], in the normal case, you hit the 'Back' button in your browser it will bring you back to '/about'.
But once you use 'replace', it will replace ['/', '/about'] to ['/', '/contact']. So you when hit 'Back' button , you will back to '/'.
最新文章
- 使用Entity Framework 自动产生的Sql语句
- View Properties [AX 2012]
- Python学习教程(learning Python)--2.3.2 Python函数实参详解
- Oracle VM Virtual 下CentOS不能自动获取IP地址
- WebService开发实例(Axis2实现,无需安装,快速实现)
- ASP.NET MVC+EF框架+EasyUI实现权限管理系列(20)-多条件模糊查询和回收站还原的实现
- js 基础对象一
- ant使用
- b2b2c
- Java IO 整理
- C#的多样性,new,sealed方法
- USB接口禁用与启用
- Go Example--json
- Spring Boot入门(2)使用MySQL数据库
- 【转】Linux下查看系统配置
- Centos7.3_x86_64通过systemctl控制tomcat8.0.46启动和停止
- Python基础【day01】:python介绍发展史(一)
- eclipse导入class文件
- 什么是PHP无限级分类
- MySQL 报错记录
热门文章
- [TS] Implement a doubly linked list in TypeScript
- 妙味css3课程---1-1、css中自定义属性可以用属性选择器么
- Shell中反引号(`)与$()用法的区别
- select into from 与 insert into select 区别
- Weblogic问题汇总
- React render return 空行问题
- Flask项目之手机端租房网站的实战开发(十二)
- amazeui学习笔记--css(常用组件15)--CSS动画Animation
- input选中 和 select点击下拉选择获取选中选项的值
- Dynamics CRM 2015/2016 Web API:Unbound Function 和 Bound Function