Created
May 22, 2018 07:53
-
-
Save kettanaito/52cc53db7ee81001ccae97de0e02f39c to your computer and use it in GitHub Desktop.
Redux - Selector
This file contains hidden or 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 React from 'react' | |
import { connect } from 'react-redux' | |
import { getTotalPrice } from './cart/selectors' | |
class Cart extends React.Component { | |
render() { | |
const { items, totalPrice } = this.props | |
return ( | |
<div> | |
<h3>Items</h3> | |
{this.renderItems(items)} | |
<p>Total price: {totalPrice}.</p> | |
</div> | |
) | |
} | |
} | |
export default connect(state => ({ | |
items: state.getIn(['cart', 'items']), | |
totalPrice: getTotalPrice(state.get('cart')) | |
})(Cart) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment