/ src / modules / App / Router.jsx
Router.jsx
 1  import React from 'react'
 2  import PropTypes from 'prop-types'
 3  import { Route, Switch } from 'react-router-dom'
 4  import Home from '../Home'
 5  import Filtered from '../Filtered'
 6  import RecentlyAdded from '../RecentlyAdded'
 7  import Profile from '../Profile'
 8  import Dapps from '../Dapps'
 9  import Vote from '../Vote'
10  import Submit from '../Submit'
11  import Terms from '../Terms/Terms'
12  import TransactionStatus from '../TransactionStatus'
13  import Alert from '../Alert'
14  import HowToSubmit from '../HowToSubmit'
15  
16  class Router extends React.Component {
17    componentDidMount() {
18      const { fetchAllDapps } = this.props
19      fetchAllDapps()
20    }
21  
22    render() {
23      return [
24        <Switch key={1}>
25          <Route exact path="/" component={Home} />
26          <Route path="/categories/:id" component={Filtered} />
27          <Route path="/all" component={Dapps} />
28          <Route path="/recently-added" component={RecentlyAdded} />
29          <Route path="/terms" component={Terms} />
30          <Route path="/:dapp_name" component={Profile} />
31        </Switch>,
32        <Vote key={2} />,
33        <Submit key={3} />,
34        <HowToSubmit key={4} />,
35        <TransactionStatus key={5} />,
36        <Alert key={6} />,
37      ]
38    }
39  }
40  
41  Router.propTypes = {
42    fetchAllDapps: PropTypes.func.isRequired,
43  }
44  
45  export default Router