[React Router v4] Render Nested Routes
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的更多相关文章
- [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] 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 ...
- [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 ...
- [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 ...
- [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. ...
- [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 ...
随机推荐
- iOS开发RunLoop学习:一:RunLoop简单介绍
一:RunLoop的简单介绍 #import "ViewController.h" @interface ViewController () @end @implementatio ...
- BAT面试题 - 找一个无序实数数组中的最大差值
题目描写叙述: 一个无序的实数数组a[i].要求求里面大小相邻的实数的差的最大值.比方 double a[]={1,5,4,0.2,100} 这个无序的数组,相邻的数的最大差值为100-5=95. 题 ...
- [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''<h1 style="text-align: center;">php
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL s ...
- javascript预解释中的机制
预解释是一种毫无节操的机制(自从学了预解释,从此节操是路人) in:‘num’ in window 判断num是否为window这个对象的一个属性,是的话返回true,不是返回false 1.预解释的 ...
- SQL判断空值、nvl处理与JOIN的使用
LIKE子句会影响查询性能,所以在明确知道字符个数时,应该使用'_',而不使用'%'. 判断空值/非空值 SELECT select_list FROM table_list/view_list WH ...
- Spring5源码深度解析(一)之理解Configuration注解
代码地址:https://github.com/showkawa/spring-annotation/tree/master/src/main/java/com/brian 1.Spring体系结构 ...
- python3中sum
摘自https://blog.csdn.net/ikerpeng/article/details/17026011 其实python中sum有两种 一种是python自己的sum 另一种是python ...
- windows apache 跳转 tomcat 代理
需求是这样的 服务器有tomcat和apache两个服务器 t端口号是8080,a端口是80 比如javaweb的域名是 www.XXX.com:8080 phpweb的域名是 a.XXX.com ...
- @EnableAsync和@Async开始异步任务支持
Spring通过任务执行器(TaskExecutor)来实现多线程和并发编程.使用ThreadPoolTaskExecutor可实现一个基于线程池的TaskExecutor.在开发中实现异步任务,我们 ...
- ArcGIS IQueryFilter接口
樱木 原文IQueryFilter 1.IQueryFilter::SubFields (1)默认值为“*”,即查询时返回整行数据,如果只需要某一个字段数据(比如“Country”字段),则可以指定 ...