Skip to content

Commit

Permalink
feat: add router and HomeContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
mori-dev committed Nov 30, 2016
1 parent 849b186 commit 3338cee
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
24 changes: 24 additions & 0 deletions src/containers/home_container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @flow
import React, { Component } from 'react';
import { connect } from 'react-redux';

function mapStateToProps(state: Object): Object {
return {};
}

function mapDispatchToProps(dispatch: Function): Object {
return {};
}

class HomeContainer extends Component {
props: {};
render() {
return (
<div>
<h1>HomeContainer</h1>
</div>
);
}
}

export default connect(mapStateToProps, mapDispatchToProps)(HomeContainer);
10 changes: 5 additions & 5 deletions src/containers/main_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ function mapDispatchToProps(dispatch: Function): Object {
}

class MainContainer extends Component {

props: {};

props: {
children: any;
};
render() {
return (
<div>
<AppBar title={'Template App'} />
<h1>HELLO WORLD</h1>
<AppBar title={'MainContainer'} />
{this.props.children}
</div>
);
}
Expand Down
10 changes: 9 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@ import { Provider } from 'react-redux';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import injectTapEventPlugin from 'react-tap-event-plugin';
import { Router, Route, hashHistory, IndexRoute } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import configureStore from './store/configure_store';
import MainContainer from './containers/main_container';
import HomeContainer from './containers/home_container';

export const store = configureStore();
const history = syncHistoryWithStore(hashHistory, store);

// https://github.com/callemall/material-ui/issues/4670
injectTapEventPlugin();

ReactDOM.render(
<Provider store={store}>
<MuiThemeProvider muiTheme={getMuiTheme()}>
<MainContainer />
<Router history={history}>
<Route path="/" component={MainContainer} >
<IndexRoute component={HomeContainer} />
</Route>
</Router>
</MuiThemeProvider>
</Provider>,
document.getElementById('root'),
Expand Down

0 comments on commit 3338cee

Please sign in to comment.