Skip to content

Instantly share code, notes, and snippets.

@bietkul
Created February 11, 2019 20:47
Show Gist options
  • Save bietkul/ebcb8c7ab3153bb719b77ecd6b823857 to your computer and use it in GitHub Desktop.
Save bietkul/ebcb8c7ab3153bb719b77ecd6b823857 to your computer and use it in GitHub Desktop.
Product reducer
import AppConstants from '../utils/constants';
const initialProductState = {
error: undefined,
product: undefined,
loading: false,
};
function product(state = initialProductState, action) {
switch (action.type) {
case AppConstants.PRODUCT.GET:
return {
...initialProductState,
loading: true
};
case AppConstants.PRODUCT.GET_SUCCESS:
return {
...state,
product: action.payload,
loading: false
};
case AppConstants.PRODUCT.GET_ERROR:
return {
...state,
error: action.error,
loading: false
};
default:
return state;
}
}
export default product;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment