Last active
June 15, 2018 10:06
-
-
Save Abazhenov/b4fc6e9b035866458a952cee241aea98 to your computer and use it in GitHub Desktop.
connect decorator example
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' | |
const mapStateToProps = (state) => { | |
return { users: state.users }; | |
} | |
const mapDispatchToProps = (dispatch, ownProps) { | |
return { | |
getUser(id) { | |
dispatch(ownProps.getUser(id)) | |
} | |
} | |
} | |
@connect(mapStateToProps, mapDispatchToProps) | |
export default class MyFancyComponent extends React.Component { | |
// react things in here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is missing an arrow
=>
on line 8