Created
January 29, 2018 22:36
-
-
Save puzzfuzz/1b2c303dc3eaff5b183a7cdd07d3eb92 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
/** src/reducers/cart.js **/ | |
const initialState = { | |
...window.shopifyData.cart, // Rehydrate cart state from server data | |
isUpdating: false | |
}; | |
const cart = (state = initialState, action) => { // Bootstrap initial state | |
switch (action.type) { | |
case 'CART_IS_UPDATING': { | |
return { | |
...state, | |
isUpdating: true | |
}; | |
} | |
case 'CART_UPDATED': { | |
const { newCart } = action; | |
return { | |
...state, | |
...newCart, | |
isUpdating: false | |
}; | |
} | |
default: | |
return state; | |
} | |
}; | |
export default cart; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment