Last active
March 5, 2019 19:42
-
-
Save 3nvi/3d75a87adb7fa6d5bb2f5ff9eb4f89f1 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
// actions.js | |
export const fireAction = item => ({ type: 'ACTION', payload: { item } }); | |
// Component.jsx | |
import React from 'react'; | |
import { connect } from 'react-redux'; | |
import { getItems } from './selectors'; | |
function MyComponent({ item, fireActionWithItem }) { | |
return <button onClick={fireActionWithItem}>{item}</button> | |
} | |
const mapDispatchToProps = (dispatch, ownProps) => ({ | |
fireActionWithItem: () => dispatch(fireAction(ownProps.item)) | |
}); | |
export default connect(null, mapDispatchToProps)(MyComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment