-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMain.js
38 lines (33 loc) · 1006 Bytes
/
Main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import PropTypes from 'prop-types';
import React from 'react';
import { Route, Switch, withRouter } from 'react-router';
// Views
import About from '../views/About';
import Help from '../views/Help';
import Home from '../views/Home';
import NotFound from '../views/NotFound';
import Search from '../views/Search';
class Main extends React.Component {
componentDidUpdate(prevProps) {
if (this.props.location !== prevProps.location) {
window.scrollTo(0, 0);
}
}
render() {
return (
<Switch>
<Route exact path="/about" component={About} />
<Route exact path="/search" component={Search} />
<Route exact path="/search/:id" component={Search} />
<Route exact path="/help" render={Help.render} />
<Route exact path="/" component={Home} />
<Route component={NotFound} />
</Switch>
);
}
}
Main.propTypes = {
isAuthenticated: PropTypes.bool,
location: PropTypes.object.isRequired
};
export default withRouter(Main);