Skip to content

Instantly share code, notes, and snippets.

@Abazhenov
Last active June 15, 2018 10:06
Show Gist options
  • Save Abazhenov/b4fc6e9b035866458a952cee241aea98 to your computer and use it in GitHub Desktop.
Save Abazhenov/b4fc6e9b035866458a952cee241aea98 to your computer and use it in GitHub Desktop.
connect decorator example
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
}
@benmerckx
Copy link

This is missing an arrow => on line 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment