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
// Rigging.js | |
class Rigging { | |
/* ... */ | |
cartUpdated = (newCart) => { | |
this.dispatch(cartActions.cartUpdated(newCart)); | |
}; | |
} | |
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
// RiggingApp.js | |
class RiggingApp { | |
constructor({ componentClass, mountSites }) { /*...*/ } | |
setStore(store) { | |
// scope a reference of the store to pass to app instances | |
this.store = store; | |
} | |
init() { /* forEach mountsite: _initMountSite */ } |
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
// CartController.jsx | |
@CartContainer | |
export default class CartController extends Component { | |
static propTypes = { | |
cart: PropTypes.object.isRequired, | |
adjustQuantity: PropTypes.func.isRequired | |
}; | |
render() { | |
const { cart, adjustQuantity } = this.props; |
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
const store = createStore(/* ... */); | |
// ... | |
ReactDOM.render( | |
<Provider store={store}> | |
<MyCompA /> | |
</Provider>, | |
document.getElementById('mountsite-A') | |
); |
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': { |
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
<!-- snippets/_data-cart.liquid --> | |
<script type="text/javascript"> | |
window.shopifyData = window.shopifyData || {}; | |
window.shopifyData.cart = {{ cart | json }}; | |
</script> | |
<!-- snippets/_data-product.liquid --> | |
<script type="text/javascript"> | |
window.shopifyData = window.shopifyData || {}; | |
window.shopifyData.currentProduct = {{ product | json }}; |
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
{ | |
"env": { | |
"es6": true, | |
"browser": true | |
}, | |
"ecmaFeatures": { | |
"modules": true, | |
"jsx": true | |
} | |
} |