File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -17,5 +17,6 @@ <h1>React Router Examples</h1>
17
17
< li > < a href ="passing-props-to-children "> Passing Props to Children</ a > </ li >
18
18
< li > < a href ="pinterest "> Pinterest-style UI (< code > location.state</ code > )</ a > </ li >
19
19
< li > < a href ="query-params "> Query Params</ a > </ li >
20
+ < li > < a href ="route-no-match "> Route Not Found</ a > </ li >
20
21
< li > < a href ="sidebar "> Sidebar</ a > </ li >
21
22
</ ul >
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { render } from 'react-dom'
3
+ import { browserHistory , Router , Route , Link } from 'react-router'
4
+
5
+ class User extends React . Component {
6
+ render ( ) {
7
+ let { userID } = this . props . params
8
+ let { query } = this . props . location
9
+ let age = query && query . showAge ? '33' : ''
10
+
11
+ return (
12
+ < div className = "User" >
13
+ < h1 > User id: { userID } </ h1 >
14
+ { age }
15
+ </ div >
16
+ )
17
+ }
18
+ }
19
+
20
+ class App extends React . Component {
21
+ render ( ) {
22
+ return (
23
+ < div >
24
+ < ul >
25
+ < li > < Link to = "/user/bob" activeClassName = "active" > Bob</ Link > </ li >
26
+ < li > < Link to = { { pathname : '/user/bob' , query : { showAge : true } } } activeClassName = "active" > Bob With Query Params</ Link > </ li >
27
+ < li > < Link to = "/user/sally" activeClassName = "active" > Sally</ Link > </ li >
28
+ </ ul >
29
+ { this . props . children }
30
+ </ div >
31
+ )
32
+ }
33
+ }
34
+
35
+ class PageNotFound extends React . Component {
36
+ render ( ) {
37
+ return (
38
+ < div >
39
+ < h1 > Page Not Found.</ h1 >
40
+ < p > Go to < Link to = "/" > Home Page</ Link > </ p >
41
+ </ div >
42
+ )
43
+ }
44
+ }
45
+
46
+ render ( (
47
+ < Router history = { browserHistory } >
48
+ < Route path = "/" component = { App } >
49
+ < Route path = "user/:userID" component = { User } />
50
+ </ Route >
51
+ < Route path = "*" component = { PageNotFound } />
52
+ </ Router >
53
+ ) , document . getElementById ( 'example' ) )
Original file line number Diff line number Diff line change
1
+ <!doctype html public "restroom">
2
+ < title > Route Not Found Example</ title >
3
+ < base href ="/route-no-match "/>
4
+ < link href ="/global.css " rel ="stylesheet "/>
5
+ < body >
6
+ < h1 class ="breadcrumbs "> < a href ="/ "> React Router Examples</ a > / Route Not Found</ h1 >
7
+ < div id ="example "/>
8
+ < script src ="/__build__/shared.js "> </ script >
9
+ < script src ="/__build__/route-no-match.js "> </ script >
You can’t perform that action at this time.
0 commit comments