reducer & store setup

This commit is contained in:
Colin Megill
2017-10-04 01:06:24 -07:00
parent 61636c23cf
commit abd070428b
2 changed files with 37 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
const Cells = (state = {
cells: null,
loading: null,
error: null,
}, action) => {
switch (action.type) {
case "REQUEST_CELLS":
return Object.assign({}, state, {
loading: true,
error: null
});
case "RECEIVE_CELLS":
return Object.assign({}, state, {
error: null,
cells: action.data,
});
case "CELLS_FETCH_ERROR":
return Object.assign({}, state, {
cells: null,
error: action.data
});
default:
return state;
}
};
export default Cells;
+10
View File
@@ -0,0 +1,10 @@
import { combineReducers, createStore } from 'redux'
import cells from './cells'
const Reducer = combineReducers({
cells,
})
let store = createStore(Reducer);
export default store;