With React Router v4 the entire library is built as a series of React components. That means that creating nested Routes is as simple as creating any other nested element in your application.

Parent route:

<NavLink to="/menu">Menu</NavLink>

<Route path="/menu" component={Menu}></Route>

Child route:

import React from 'react';
import {Link, Route} from 'react-router-dom'; const Menu = () => (
<div>
<h1>Menu</h1>
<Link to="/menu/food" >Food</Link>
<Link to="/menu/drinks">Drinks</Link>
<Link to="/menu/slides">Slides</Link> <Route path="/menu/:section" render={({match}) => {
return <h3>Section: {match.params.section}</h3>
}}>
</Route>
</div>
); export default Menu;

[React Router v4] Render Nested Routes的更多相关文章

  1. [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 ...

  2. [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 ca ...

  3. [React Router v4] Create Basic Routes with the React Router v4 BrowserRouter

    React Router 4 has several routers built in for different purposes. The primary one you will use for ...

  4. [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 ...

  5. [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. ...

  6. [Web 前端] React Router v4 入坑指南

    cp from : https://www.jianshu.com/p/6a45e2dfc9d9 万恶的根源 距离React Router v4 正式发布也已经过去三个月了,这周把一个React的架子 ...

  7. [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 ...

  8. [React Router v4] Redirect to Another Page

    Overriding a browser's current location without breaking the back button or causing an infinite redi ...

  9. [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 ...

随机推荐

  1. C# Aspect-Oriented Programming(AOP) 利用多种模式实现动态代理

    什么是AOP(Aspect-Oriented Programming)? AOP允许开发者动态地修改静态的OO模型,构造出一个能够不断增长以满足新增需求的系统,就象现实世界中的对象会在其生命周期中不断 ...

  2. SQL-android uri的使用(转载)

    今天在操作android的时候,用到了数据库的访问,就在网上学习了一下关于数据库的知识.其中访问数据库就是通过uri进行的,所以这里总结下android uri的应用. 以下内容参考http://ww ...

  3. 笔记二:JS的输出、语法、语句、字符串、条件语句、switch语句、for循环、while循环

    1.JS的输出: 注意:JS没有任何打印或者输出的函数 JS输出数据的集中方法:  1.使用window.alert()弹出警告框: 2.使用document.write()方法将内容写到HTML文档 ...

  4. Css 显示删除条目效果

    样式设置

  5. loadrunner监控apache服务

    一.apache配置步骤(假设apache服务已安装) 1.使用find / -name httpd.conf命令查找httpd.conf文件 2.使用cd opt/lampp/apache2/con ...

  6. [React] Remove React PropTypes by using Flow Annotations (in CRA)

    Starting from v15.5 if we wanted to use React's PropTypes we had to change our code to use a separat ...

  7. JS学习笔记 - 自定义右键菜单、文本框只能输入数字

    <script> // 事件总共有2个部分, //1.点击鼠标右键的表现 oncontextmenu 2.点击鼠标左键的表现(即普通点击onclick) // 点击右键,div位置定位到鼠 ...

  8. 1、移动端 2、后台 3、 移动端,Web 端 4、 PC端

    移动端: 1.公众号:停开心 住总物业 2.app:  iso Android 停开心,住总停开心 后台:停开心智慧停车管理平台(所有的停车场) 移动端,Web端: 海投OA,公司OA PC端:收费软 ...

  9. SQL Server2008 Hierarchyid数据类型

    以往我们在关系数据库中建立树状结构的时候,通常使用ID+ParentID来实现两条 纪录间的父子关系.但这种方式只能标示其相对位置.解决这类问题在SqlServer2005出现之前通常是采用游标来操作 ...

  10. leetcode——Reverse Linked List II 选择链表中部分节点逆序(AC)

    Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1-> ...