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';
22import 'bootstrap' ;
33import * as React from 'react' ;
44import * as ReactDOM from 'react-dom' ;
5- import { browserHistory , Router } from 'react-router' ;
5+ import { BrowserRouter as Router } from 'react-router-dom ' ;
66import routes from './routes' ;
77
88// This code starts up the React app when it runs in a browser. It sets up the routing configuration
99// and injects the app into a DOM element.
1010ReactDOM . render (
11- < Router history = { browserHistory } children = { routes } /> ,
11+ < Router children = { routes } /> ,
1212 document . getElementById ( 'react-app' )
1313) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import * as React from 'react';
22import { NavMenu } from './NavMenu' ;
33
44export interface LayoutProps {
5- body : React . ReactElement < any > ;
5+ children ? : React . ReactNode ;
66}
77
88export class Layout extends React . Component < LayoutProps , { } > {
@@ -13,7 +13,7 @@ export class Layout extends React.Component<LayoutProps, {}> {
1313 < NavMenu />
1414 </ div >
1515 < div className = 'col-sm-9' >
16- { this . props . body }
16+ { this . props . children }
1717 </ div >
1818 </ div >
1919 </ div > ;
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2- import { Link } from 'react-router' ;
2+ import { Link , NavLink } from 'react-router-dom ' ;
33
44export class NavMenu extends React . Component < { } , { } > {
55 public render ( ) {
@@ -18,19 +18,19 @@ export class NavMenu extends React.Component<{}, {}> {
1818 < div className = 'navbar-collapse collapse' >
1919 < ul className = 'nav navbar-nav' >
2020 < li >
21- < Link to = { '/' } activeClassName = 'active' >
21+ < NavLink to = { '/' } exact activeClassName = 'active' >
2222 < span className = 'glyphicon glyphicon-home' > </ span > Home
23- </ Link >
23+ </ NavLink >
2424 </ li >
2525 < li >
26- < Link to = { '/counter' } activeClassName = 'active' >
26+ < NavLink to = { '/counter' } activeClassName = 'active' >
2727 < span className = 'glyphicon glyphicon-education' > </ span > Counter
28- </ Link >
28+ </ NavLink >
2929 </ li >
3030 < li >
31- < Link to = { '/fetchdata' } activeClassName = 'active' >
31+ < NavLink to = { '/fetchdata' } activeClassName = 'active' >
3232 < span className = 'glyphicon glyphicon-th-list' > </ span > Fetch data
33- </ Link >
33+ </ NavLink >
3434 </ li >
3535 </ ul >
3636 </ div >
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2- import { Router , Route , HistoryBase } from 'react-router' ;
2+ import { Route } from 'react-router-dom ' ;
33import { Layout } from './components/Layout' ;
44import { Home } from './components/Home' ;
55import { FetchData } from './components/FetchData' ;
66import { Counter } from './components/Counter' ;
77
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 > ;
1313
1414// Allow Hot Module Reloading
1515declare var module : any ;
You can’t perform that action at this time.
0 commit comments