File tree Expand file tree Collapse file tree 2 files changed +8
-18
lines changed Expand file tree Collapse file tree 2 files changed +8
-18
lines changed Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react'
2
2
import NotFoundImage from '../assets/404.jpg'
3
3
import classes from './PageNotFound.scss'
4
+ import { withRouter } from 'react-router' ;
4
5
5
- export default class PageNotFound extends Component {
6
+ class PageNotFound extends Component {
6
7
7
8
back ( ) {
8
- console . log ( this . props . router ) ;
9
+ this . props . router . goBack ( )
9
10
}
10
11
11
12
render ( ) {
@@ -21,3 +22,4 @@ export default class PageNotFound extends Component{
21
22
)
22
23
}
23
24
}
25
+ export default withRouter ( PageNotFound )
Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react'
2
- import { Link } from 'react-router' ;
2
+ import { Link , withRouter } from 'react-router' ;
3
3
4
4
class Route extends Component {
5
5
6
- /*componentDidMount() {
7
- this.props.router.setRouteLeaveHook(this.props.route, this.routerWillLeave)
8
- }
9
-
10
- routerWillLeave(nextLocation) {
11
- return 'Your work is not saved! Are you sure you want to leave?'
12
- }*/
13
-
14
6
redirect ( ) {
15
- console . log ( this . props ) ;
16
- }
17
-
18
- componentWillReceiveProps ( nextProps ) {
19
- console . log ( nextProps . params . id )
7
+ this . props . router . push ( '/form' )
20
8
}
21
9
22
10
render ( ) {
@@ -25,7 +13,7 @@ class Route extends Component {
25
13
return (
26
14
< div >
27
15
< h1 >
28
- Path: < Link to = "/route/99 " > { location . pathname } </ Link >
16
+ Path: < Link to = "/form " > { location . pathname } </ Link >
29
17
</ h1 >
30
18
< div >
31
19
< button onClick = { this . redirect . bind ( this ) } > Go</ button >
@@ -34,4 +22,4 @@ class Route extends Component {
34
22
)
35
23
}
36
24
}
37
- export default Route
25
+ export default withRouter ( Route )
You can’t perform that action at this time.
0 commit comments