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. 洛谷 P1760 通天之汉诺塔

    P1760 通天之汉诺塔 题目背景 直达通天路·小A历险记第四篇 题目描述 在你的帮助下,小A成功收集到了宝贵的数据,他终于来到了传说中连接通天路的通天山.但是这距离通天路仍然有一段距离,但是小A突然 ...

  2. setInterval()第一个参数带引号和不带引号的区别

    setInterval()第一个参数带引号和不带引号的区别:关于定时函数setInterval()的基本用法这里就不做介绍了,查阅相关教程即可,这里主要介绍一下setInterval()函数的第一个参 ...

  3. 前端面试题(JavaScript)

    (前端面试题大全,持续更新) 箭头函数特点?箭头函数和普通函数的区别 手写懒加载(考虑防抖和重复加载问题) 手写bind(为什么要加预参数,为什么要加new) apply, call, bind ne ...

  4. POJ2029:Get Many Persimmon Trees(二维树状数组)

    Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aiz ...

  5. 12.SpringBoot+MyBatis(XML)+Druid

    转自:https://www.cnblogs.com/MaxElephant/p/8108342.html 主要是在Spring Boot中集成MyBatis,可以选用基于注解的方式,也可以选择xml ...

  6. iOS_02_第一个C语言程序(理解编译、连接、运行)

    一.开发工具的选择 1. 可以用来写代码的工具:记事本.ULtraEdit.Vim.Xcode等. 2. 选择XCode的原因:苹果公司官方提供的开发利器.简化开发的工程.有高亮显示功能. 3. 使用 ...

  7. 每日技术总结:setx,

    1.setx命令设置环境变量 设置用户环境变量: setx NAME "XXX" 设置系统环境变量: setx NAME "XXX" /m

  8. multi_input_paths

  9. C语言深度剖析-----数组与指针分析

    数组的本质: 指针的运算: 小标VS指针: a和&a的区别: 例: 数组参数: 所以下例返回4 指针和数组的对比小结:

  10. static 静态

    摘自:https://blog.csdn.net/Kendiv/article/details/675941 关于static的  ""记忆性"" 我们可以用做 ...