2016-10-20 04:14:26 +03:00
|
|
|
const React = require('react');
|
|
|
|
const ReactRedux = require('react-redux');
|
|
|
|
const ReactRouter = require('react-router');
|
|
|
|
|
2016-12-05 22:28:10 +02:00
|
|
|
const actions = require('@state/actions');
|
|
|
|
const Home = require('@containers/home');
|
|
|
|
const NotFound = require('@containers/not-found');
|
2016-10-20 04:14:26 +03:00
|
|
|
|
|
|
|
const {
|
|
|
|
updateRouter
|
|
|
|
} = actions;
|
|
|
|
|
|
|
|
const {
|
|
|
|
connect
|
|
|
|
} = ReactRedux;
|
|
|
|
|
|
|
|
const {
|
|
|
|
Miss,
|
|
|
|
Match
|
|
|
|
} = ReactRouter;
|
|
|
|
|
|
|
|
const App = connect()(React.createClass({
|
2016-10-25 22:15:33 +03:00
|
|
|
propTypes: {
|
|
|
|
children: React.PropTypes.node,
|
|
|
|
dispatch: React.PropTypes.func,
|
|
|
|
router: React.PropTypes.object
|
|
|
|
},
|
2016-10-20 04:14:26 +03:00
|
|
|
componentWillMount: function() {
|
|
|
|
const {
|
|
|
|
router,
|
|
|
|
dispatch
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
// ugly hack needed because of a limitation of react-router api
|
|
|
|
// that doens't pass it's instance to matched routes
|
2016-10-20 22:42:39 +03:00
|
|
|
// wait for react-router-redux@5
|
2016-10-20 04:14:26 +03:00
|
|
|
dispatch(updateRouter(router));
|
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
const {
|
|
|
|
children
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
if (!Array.isArray(children)) {
|
|
|
|
return children;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
module.exports = (props) => {
|
|
|
|
return (
|
|
|
|
<App {...props}>
|
2016-10-25 22:15:33 +03:00
|
|
|
<Match
|
|
|
|
component={Home}
|
|
|
|
exactly
|
|
|
|
pattern='/'
|
|
|
|
/>
|
|
|
|
<Miss
|
|
|
|
component={NotFound}
|
|
|
|
/>
|
2016-10-20 04:14:26 +03:00
|
|
|
</App>
|
|
|
|
);
|
|
|
|
};
|