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 '/'.

最新文章

  1. 使用Entity Framework 自动产生的Sql语句
  2. View Properties [AX 2012]
  3. Python学习教程(learning Python)--2.3.2 Python函数实参详解
  4. Oracle VM Virtual 下CentOS不能自动获取IP地址
  5. WebService开发实例(Axis2实现,无需安装,快速实现)
  6. ASP.NET MVC+EF框架+EasyUI实现权限管理系列(20)-多条件模糊查询和回收站还原的实现
  7. js 基础对象一
  8. ant使用
  9. b2b2c
  10. Java IO 整理
  11. C#的多样性,new,sealed方法
  12. USB接口禁用与启用
  13. Go Example--json
  14. Spring Boot入门(2)使用MySQL数据库
  15. 【转】Linux下查看系统配置
  16. Centos7.3_x86_64通过systemctl控制tomcat8.0.46启动和停止
  17. Python基础【day01】:python介绍发展史(一)
  18. eclipse导入class文件
  19. 什么是PHP无限级分类
  20. MySQL 报错记录

热门文章

  1. [TS] Implement a doubly linked list in TypeScript
  2. 妙味css3课程---1-1、css中自定义属性可以用属性选择器么
  3. Shell中反引号(`)与$()用法的区别
  4. select into from 与 insert into select 区别
  5. Weblogic问题汇总
  6. React render return 空行问题
  7. Flask项目之手机端租房网站的实战开发(十二)
  8. amazeui学习笔记--css(常用组件15)--CSS动画Animation
  9. input选中 和 select点击下拉选择获取选中选项的值
  10. Dynamics CRM 2015/2016 Web API:Unbound Function 和 Bound Function