File tree Expand file tree Collapse file tree 4 files changed +17
-17
lines changed
templates/ReactSpa/ClientApp Expand file tree Collapse file tree 4 files changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,12 @@ import './css/site.css';
2
2
import 'bootstrap' ;
3
3
import * as React from 'react' ;
4
4
import * as ReactDOM from 'react-dom' ;
5
- import { browserHistory , Router } from 'react-router' ;
5
+ import { BrowserRouter as Router } from 'react-router-dom ' ;
6
6
import routes from './routes' ;
7
7
8
8
// This code starts up the React app when it runs in a browser. It sets up the routing configuration
9
9
// and injects the app into a DOM element.
10
10
ReactDOM . render (
11
- < Router history = { browserHistory } children = { routes } /> ,
11
+ < Router children = { routes } /> ,
12
12
document . getElementById ( 'react-app' )
13
13
) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import * as React from 'react';
2
2
import { NavMenu } from './NavMenu' ;
3
3
4
4
export interface LayoutProps {
5
- body : React . ReactElement < any > ;
5
+ children ? : React . ReactNode ;
6
6
}
7
7
8
8
export class Layout extends React . Component < LayoutProps , { } > {
@@ -13,7 +13,7 @@ export class Layout extends React.Component<LayoutProps, {}> {
13
13
< NavMenu />
14
14
</ div >
15
15
< div className = 'col-sm-9' >
16
- { this . props . body }
16
+ { this . props . children }
17
17
</ div >
18
18
</ div >
19
19
</ div > ;
Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
- import { Link } from 'react-router' ;
2
+ import { Link , NavLink } from 'react-router-dom ' ;
3
3
4
4
export class NavMenu extends React . Component < { } , { } > {
5
5
public render ( ) {
@@ -18,19 +18,19 @@ export class NavMenu extends React.Component<{}, {}> {
18
18
< div className = 'navbar-collapse collapse' >
19
19
< ul className = 'nav navbar-nav' >
20
20
< li >
21
- < Link to = { '/' } activeClassName = 'active' >
21
+ < NavLink to = { '/' } exact activeClassName = 'active' >
22
22
< span className = 'glyphicon glyphicon-home' > </ span > Home
23
- </ Link >
23
+ </ NavLink >
24
24
</ li >
25
25
< li >
26
- < Link to = { '/counter' } activeClassName = 'active' >
26
+ < NavLink to = { '/counter' } activeClassName = 'active' >
27
27
< span className = 'glyphicon glyphicon-education' > </ span > Counter
28
- </ Link >
28
+ </ NavLink >
29
29
</ li >
30
30
< li >
31
- < Link to = { '/fetchdata' } activeClassName = 'active' >
31
+ < NavLink to = { '/fetchdata' } activeClassName = 'active' >
32
32
< span className = 'glyphicon glyphicon-th-list' > </ span > Fetch data
33
- </ Link >
33
+ </ NavLink >
34
34
</ li >
35
35
</ ul >
36
36
</ div >
Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
- import { Router , Route , HistoryBase } from 'react-router' ;
2
+ import { Route } from 'react-router-dom ' ;
3
3
import { Layout } from './components/Layout' ;
4
4
import { Home } from './components/Home' ;
5
5
import { FetchData } from './components/FetchData' ;
6
6
import { Counter } from './components/Counter' ;
7
7
8
- export default < Route component = { Layout } >
9
- < Route path = '/' components = { { body : Home } } />
10
- < Route path = '/counter' components = { { body : Counter } } />
11
- < Route path = '/fetchdata' components = { { body : FetchData } } />
12
- </ Route > ;
8
+ export default < Layout >
9
+ < Route exact path = '/' component = { Home } />
10
+ < Route path = '/counter' component = { Counter } />
11
+ < Route path = '/fetchdata' component = { FetchData } />
12
+ </ Layout > ;
13
13
14
14
// Allow Hot Module Reloading
15
15
declare var module : any ;
You can’t perform that action at this time.
0 commit comments