Skip to content

Commit

Permalink
feat: add /another
Browse files Browse the repository at this point in the history
  • Loading branch information
mori-dev committed Dec 1, 2016
1 parent aa28ba3 commit 8bd8feb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/containers/another_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 AnotherContainer extends Component {
props: {};
render() {
return (
<div>
<h1>AnotherContainer</h1>
</div>
);
}
}

export default connect(mapStateToProps, mapDispatchToProps)(AnotherContainer);
6 changes: 5 additions & 1 deletion src/containers/main_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { Component } from 'react';
import { connect } from 'react-redux';
import AppBar from 'material-ui/AppBar';
import { Link } from 'react-router';
import { List, ListItem } from 'material-ui/List';

function mapStateToProps(state: Object): Object {
return {};
Expand All @@ -20,7 +21,10 @@ class MainContainer extends Component {
return (
<div>
<AppBar title={'MainContainer'} />
<Link to={'/home'}> /home へ遷移 </Link>
<List>
<ListItem><Link to={'/home'}> /home へ遷移して HomeContainer をマウント </Link></ListItem>
<ListItem><Link to={'/another'}> /another へ遷移して AnotherContainer をマウント </Link></ListItem>
</List>
{this.props.children}
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { syncHistoryWithStore } from 'react-router-redux';
import configureStore from './store/configure_store';
import MainContainer from './containers/main_container';
import HomeContainer from './containers/home_container';
import AnotherContainer from './containers/another_container';

export const store = configureStore();
const history = syncHistoryWithStore(hashHistory, store);
Expand All @@ -23,6 +24,7 @@ ReactDOM.render(
<Route path="/" component={MainContainer} >
<IndexRoute component={HomeContainer} />
<Route path="/home" component={HomeContainer} />
<Route path="/another" component={AnotherContainer} />
</Route>
</Router>
</MuiThemeProvider>
Expand Down

0 comments on commit 8bd8feb

Please sign in to comment.