Created
March 4, 2019 21:45
-
-
Save 3nvi/db2e14972b89fb3a38f41a22f8b52441 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
// selectors.js | |
export const getItems = state => state.items; | |
// Component.jsx | |
import React from 'react'; | |
import { connect } from 'react-redux'; | |
import { getItems } from './selectors'; | |
function MyComponent({ items }) { | |
return <div>{items.length}</div> | |
} | |
const mapStateToProps = state => ({ items: getItems(state) }); | |
export default connect(mapStateToProps)(MyComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment