Skip to content

Instantly share code, notes, and snippets.

@muneneevans
Created November 4, 2017 10:13
Show Gist options
  • Save muneneevans/881a2b6896b43fdedad59ec0b0806039 to your computer and use it in GitHub Desktop.
Save muneneevans/881a2b6896b43fdedad59ec0b0806039 to your computer and use it in GitHub Desktop.
Reducer to handle created actions
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