Skip to content

Commit

Permalink
add Todo route
Browse files Browse the repository at this point in the history
  • Loading branch information
Chenyi LEE committed Dec 1, 2016
1 parent b9cb674 commit 8f50a3b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/routes/Todo/components/Todo.js
@@ -0,0 +1,12 @@
import React from 'react'

export const Todo = (props) => (
<div style={{ margin: '0 auto' }} >
<h2>Todo</h2>
</div>
)

Todo.propTypes = {
}

export default Todo
11 changes: 11 additions & 0 deletions src/routes/Todo/containers/TodoContainer.js
@@ -0,0 +1,11 @@
import { connect } from 'react-redux'

import Todo from '../components/Todo'

const mapDispatchToProps = {
}

const mapStateToProps = (state) => ({
})

export default connect(mapStateToProps, mapDispatchToProps)(Todo)
16 changes: 16 additions & 0 deletions src/routes/Todo/index.js
@@ -0,0 +1,16 @@
import { injectReducer } from '../../store/reducers'

export default (store) => ({
path : 'todo',
getComponent (nextState, cb) {
require.ensure([], (require) => {
const Todo = require('./containers/TodoContainer').default
const reducer = require('./modules/todo').default

injectReducer(store, { key: 'todo', reducer })

cb(null, Todo)

}, 'todo')
}
})
23 changes: 23 additions & 0 deletions src/routes/Todo/modules/todo.js
@@ -0,0 +1,23 @@
// ------------------------------------
// Constants
// ------------------------------------

// ------------------------------------
// Actions
// ------------------------------------

// ------------------------------------
// Action Handlers
// ------------------------------------
const ACTION_HANDLERS = {
}

// ------------------------------------
// Reducer
// ------------------------------------
const initialState = {}
export default function todoReducer (state = initialState, action) {
const handler = ACTION_HANDLERS[action.type]

return handler ? handler(state, action) : state
}
4 changes: 3 additions & 1 deletion src/routes/index.js
Expand Up @@ -2,6 +2,7 @@
import CoreLayout from '../layouts/CoreLayout/CoreLayout'
import Home from './Home'
import CounterRoute from './Counter'
import TodoRoute from './Todo'

/* Note: Instead of using JSX, we recommend using react-router
PlainRoute objects to build route definitions. */
Expand All @@ -11,7 +12,8 @@ export const createRoutes = (store) => ({
component : CoreLayout,
indexRoute : Home,
childRoutes : [
CounterRoute(store)
CounterRoute(store),
TodoRoute(store),
]
})

Expand Down

0 comments on commit 8f50a3b

Please sign in to comment.