-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added react-router + redux-localstorage (#14)
- Loading branch information
Showing
9 changed files
with
95 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React, { Component } from 'react'; | ||
|
||
export default class LoggedIn extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
<h2>Logged in as {this.props.user.username}</h2> | ||
</div> | ||
); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { connect } from 'react-redux'; | ||
import LoggedIn from '../components/LoggedIn'; | ||
|
||
const mapStateToProps = (state) => { | ||
return state; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch) => { // eslint-disable-line no-unused-vars | ||
return {}; | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(LoggedIn); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { connect } from 'react-redux'; | ||
import { bindActionCreators } from 'redux'; | ||
import Login from '../components/Login'; | ||
import userActions from '../actions/user'; | ||
|
||
const mapStateToProps = (state) => { | ||
return state; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch) => { | ||
const user = bindActionCreators(userActions, dispatch); | ||
return { | ||
onLogin: user.login | ||
}; | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(Login); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { Provider } from 'react-redux'; | ||
import App from './containers/App'; | ||
import configureStore from './store/default'; | ||
import { Router, hashHistory } from 'react-router'; | ||
import { syncHistoryWithStore } from 'react-router-redux'; | ||
import routes from './routes'; | ||
import configureStore from './store'; | ||
|
||
const initialState = {}; | ||
const store = configureStore(initialState); | ||
const routerHistory = syncHistoryWithStore(hashHistory, store); | ||
|
||
const rootElement = document.querySelector(document.currentScript.getAttribute('data-container')); | ||
|
||
ReactDOM.render( | ||
<Provider store={store}> | ||
<div> | ||
<App /> | ||
</div> | ||
<Router history={routerHistory} routes={routes} /> | ||
</Provider>, | ||
rootElement | ||
); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import { Route, IndexRoute } from 'react-router'; | ||
|
||
import App from './containers/App'; | ||
import LoginPage from './containers/LoginPage'; | ||
import LoggedInPage from './containers/LoggedInPage'; | ||
|
||
export default ( | ||
<Route path="/" component={App}> | ||
<IndexRoute component={LoginPage} /> | ||
<Route path="loggedin" component={LoggedInPage} /> | ||
</Route> | ||
); |
This file contains 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
This file contains 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