Skip to content

Instantly share code, notes, and snippets.

@aminbenselim
Created March 26, 2017 20:52
Show Gist options
  • Save aminbenselim/d9a3e68911d812e7dcfe87f6a4dc34a3 to your computer and use it in GitHub Desktop.
Save aminbenselim/d9a3e68911d812e7dcfe87f6a4dc34a3 to your computer and use it in GitHub Desktop.
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