Created
November 4, 2017 10:13
-
-
Save muneneevans/881a2b6896b43fdedad59ec0b0806039 to your computer and use it in GitHub Desktop.
Reducer to handle created actions
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
import * as types from "./actionTypes" | |
import Immutable from "seamless-immutable" | |
const initialState = Immutable({ | |
posts: undefined, | |
postsIsFetched: false | |
}) | |
export default function postsReducer(state=initialState, action={}){ | |
switch (action.type) { | |
case types.POSTS_RECEIVED: | |
return state.merge({ | |
posts: action.payload, | |
postsIsFetched: true | |
}) | |
default: | |
return state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment