diff --git a/src/redux/reducers/authorReducer.js b/src/redux/reducers/authorReducer.js index 1cd9d9a..6fc82c7 100644 --- a/src/redux/reducers/authorReducer.js +++ b/src/redux/reducers/authorReducer.js @@ -1,6 +1,7 @@ import * as types from "../actions/actionTypes"; +import initialState from "./initialState"; -export default function authorReducer(state = [], action) { +export default function authorReducer(state = initialState.authors, action) { switch (action.type) { case types.LOAD_AUTHORS_SUCCESS: return action.authors; diff --git a/src/redux/reducers/courseReducer.js b/src/redux/reducers/courseReducer.js index 2d09c6c..aa61ab8 100644 --- a/src/redux/reducers/courseReducer.js +++ b/src/redux/reducers/courseReducer.js @@ -1,6 +1,7 @@ import * as types from "../actions/actionTypes"; +import initialState from "./initialState"; -export default function courseReducer(state = [], action) { +export default function courseReducer(state = initialState.courses, action) { switch (action.type) { case types.CREATE_COURSE: return [...state, { ...action.course }]; diff --git a/src/redux/reducers/initialState.js b/src/redux/reducers/initialState.js new file mode 100644 index 0000000..8d2e4a3 --- /dev/null +++ b/src/redux/reducers/initialState.js @@ -0,0 +1,4 @@ +export default { + courses: [], + authors: [] +};