Skip to content

Commit f574ef9

Browse files
greenkeeper[bot]xkawi
authored andcommitted
Update react-router to the latest version 🚀 (#31)
* fix(package): update react-router to version 4.0.0 https://greenkeeper.io/ * use react-router v4
1 parent 7f3645c commit f574ef9

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"dependencies": {
1010
"react": "^15.4.0",
1111
"react-dom": "^15.4.0",
12-
"react-router": "^3.0.0"
12+
"react-router": "^4.0.0",
13+
"react-router-dom": "^4.0.0"
1314
},
1415
"scripts": {
1516
"now-start": "cd build && serve -s ./",

src/About.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react';
2-
import { Link } from 'react-router';
2+
import { Link } from 'react-router-dom';
33

44
class About extends Component {
55
render() {

src/App.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
import React, { Component } from 'react';
2-
import { Link } from 'react-router';
2+
import {
3+
BrowserRouter as Router,
4+
Route,
5+
Link,
6+
Switch,
7+
} from 'react-router-dom'
8+
import About from './About';
39
import logo from './logo.svg';
410
import './App.css';
511

12+
const NoMatch = ({ location }) => (
13+
<div>
14+
<p>No Match for <code>{location.pathname}</code></p>
15+
<Link to='/'>go back</Link>
16+
</div>
17+
)
18+
619
class App extends Component {
720
render() {
821
const secretCode = process.env.REACT_APP_SECRET_CODE;
@@ -17,10 +30,21 @@ class App extends Component {
1730
</p>
1831
<p>REACT_APP_SECRET_CODE: { !secretCode ? 'env not set yet' : secretCode }</p>
1932
<p><Link to='/about'>about us</Link></p>
20-
{this.props.children}
2133
</div>
2234
);
2335
}
2436
}
2537

26-
export default App;
38+
const BasicApp = () => (
39+
<Router>
40+
<div>
41+
<Switch>
42+
<Route exact path="/" component={App} />
43+
<Route path="/about" component={About} />
44+
<Route component={NoMatch} />
45+
</Switch>
46+
</div>
47+
</Router>
48+
)
49+
50+
export default BasicApp;

src/index.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import { Router, Route, browserHistory, Link } from 'react-router'
43
import App from './App';
5-
import About from './About';
64
import './index.css';
75

8-
const NoMatch = () => (
9-
<p>No Match <Link to='/'>go back</Link></p>
10-
)
11-
12-
ReactDOM.render((
13-
<Router history={browserHistory} >
14-
<Route path="/" component={App} />
15-
<Route path="/about" component={About}/>
16-
<Route path="*" component={NoMatch}/>
17-
</Router>
18-
), document.getElementById('root'));
6+
ReactDOM.render(
7+
<App />,
8+
document.getElementById('root')
9+
);

0 commit comments

Comments
 (0)