From 210b0885a17e57fbbb80bbf0dc30b228a7e245dc Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sat, 11 Apr 2020 23:01:54 +0300 Subject: [PATCH] initial state --- src/redux/reducers/authorReducer.js | 3 ++- src/redux/reducers/courseReducer.js | 3 ++- src/redux/reducers/initialState.js | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 src/redux/reducers/initialState.js 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: [] +};