Skip to content

Commit

Permalink
added posts reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Apr 13, 2017
1 parent 66dfdaf commit 79998a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion blog/src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { combineReducers } from 'redux';
import PostsReducer from './reducer_posts';

const rootReducer = combineReducers({
state: (state = {}) => state
posts: PostsReducer
});

export default rootReducer;
11 changes: 11 additions & 0 deletions blog/src/reducers/reducer_posts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import _ from 'lodash';
import { FETCH_POSTS } from '../actions';

export default function(state = {}, action) {
switch (action.type) {
case FETCH_POSTS:
return _.mapKeys(action.payload.data, 'id');
default:
return state;
}
}

0 comments on commit 79998a1

Please sign in to comment.