1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 18:32:50 +00:00

fixed routing

This commit is contained in:
2016-09-02 20:38:01 +00:00
parent 6bf367f9be
commit be5e95b6cf
6 changed files with 72 additions and 56 deletions

View File

@@ -12,14 +12,9 @@ import store, {history} from './redux/store';
import * as actions from './redux/actions';
import Index from './pages/Index';
class Main extends React.Component {
render() {
return (
<div>{React.cloneElement(this.props.children, this.props)}</div>
);
}
}
import Preview from './components/Preview';
import Post from './components/Post';
import SensorInfo from './components/sensors/SensorInfo';
function mapStateToProps(state) {
return {
@@ -33,14 +28,15 @@ function mapDispatchToProps(dispatch) {
}
}
const App = connect(mapStateToProps, mapDispatchToProps)(Main);
const App = connect(mapStateToProps, mapDispatchToProps)(Index);
ReactDOM.render((
<Provider store={store}>
<Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={Index}/>
<Route path="/:page(/:category)(/:post)" component={Index}/>
<IndexRoute component={Preview}/>
<Route path="post/:category/:post" component={Post}/>
<Route path="sensor/:location/:year/:month" component={SensorInfo}/>
</Route>
</Router>
</Provider>