Created
March 26, 2017 20:52
-
-
Save aminbenselim/d9a3e68911d812e7dcfe87f6a4dc34a3 to your computer and use it in GitHub Desktop.
This file contains 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 { | |
GET_POST, | |
GET_POST_SUCCESS, | |
GET_POST_FAILURE, | |
} from "./../actions/actions"; | |
const INITIAL_STATE = { post: null, error: null, loading: false }; | |
const Post = (state = INITIAL_STATE, action) => { | |
let error; | |
switch (action.type) { | |
case GET_POST: | |
return { post: null, error: null, loading: true }; | |
case GET_POST_SUCCESS: | |
return { post: action.payload, error: null, loading: false }; | |
case GET_POST_FAILURE: | |
error = action.payload | |
return { post: null, error, loading: false }; | |
default: | |
return state; | |
} | |
}; | |
export default Post; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment