Created
June 29, 2017 07:01
-
-
Save N0K0/072a003884db3195a26dd02dddbbca00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Ytre index fil for å definere ruter | |
import CoreLayout from '../layouts/PageLayout/PageLayout' | |
import Secret from './Secret' | |
import TaskView from './task-view/index' | |
export const createRoutes = (store) => ({ | |
path : '/', | |
component : CoreLayout, | |
childRoutes : [ | |
Secret(store), | |
TaskView(store) | |
] | |
}) | |
export default createRoutes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//indre indexfil for å async loade rute | |
import injectReducer from '../../store/reducers.js' | |
export default (store) => ({ | |
path : 'tasks', | |
getComponent (nextState, cb) { | |
require.ensure([], () => { | |
console.log("Route made to tasks") | |
const tasks = require('./containers/TaskViewContainer').default | |
const reducer = require('./reducers/taskViewReducer').taskViewReducer | |
console.log(reducer) | |
console.log(tasks) | |
injectReducer(store, { key: 'taskViewReducer', reducer }) | |
cb(null, tasks) | |
}, 'tasks') | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Reducer den referer til | |
const initialState = { | |
tasks : [] | |
} | |
export const taskViewReducer = function (state = initialState, action) { | |
switch (action.type) { | |
case 'FETCH_DATA': | |
console.log('FETCH_DATA') | |
return { ...state, tasks: action.tasks } | |
default: | |
console.log('Reducer ', action) | |
return state | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment