Created
December 28, 2017 17:09
-
-
Save Abazhenov/a553127aaf9067285c005231d897521f to your computer and use it in GitHub Desktop.
connect without decorator
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
import React from 'react' | |
import { connect } from 'react-redux' | |
class MyFancyComponent extends React.Component { | |
// react things in here | |
} | |
const mapStateToProps = (state) => { | |
return { users: state.users }; | |
} | |
const mapDispatchToProps = (dispatch, ownProps) { | |
return { | |
getUser(id) { | |
dispatch(ownProps.getUser(id)) | |
} | |
} | |
} | |
export default connect(mapStateToProps, mapDispatchToProps)(MyFancyComponent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment