Last active
October 21, 2016 15:20
-
-
Save bnhansn/e5766bb2f7c2119216495886aefaed67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @flow | |
| import React, { Component } from 'react'; | |
| import { BrowserRouter, Match, Miss } from 'react-router'; | |
| import { connect } from 'react-redux'; | |
| import { authenticate } from '../../actions/session'; | |
| import Home from '../Home'; | |
| import NotFound from '../../components/NotFound'; | |
| import Login from '../Login'; | |
| import Signup from '../Signup'; | |
| type Props = { | |
| authenticate: () => void, | |
| } | |
| class App extends Component { | |
| componentDidMount() { | |
| const token = localStorage.getItem('token'); | |
| if (token) { | |
| this.props.authenticate(); | |
| } | |
| } | |
| props: Props | |
| render() { | |
| return ( | |
| <BrowserRouter> | |
| <div style={{ display: 'flex', flex: '1' }}> | |
| <Match exactly pattern="/" component={Home} /> | |
| <Match pattern="/login" component={Login} /> | |
| <Match pattern="/signup" component={Signup} /> | |
| <Miss component={NotFound} /> | |
| </div> | |
| </BrowserRouter> | |
| ); | |
| } | |
| } | |
| export default connect( | |
| null, | |
| { authenticate } | |
| )(App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment