Skip to content

Instantly share code, notes, and snippets.

@Bastiani
Created September 15, 2017 17:05
Show Gist options
  • Save Bastiani/3099e79e8d188cc8eef824ac3883ea35 to your computer and use it in GitHub Desktop.
Save Bastiani/3099e79e8d188cc8eef824ac3883ea35 to your computer and use it in GitHub Desktop.
import { Component } from 'react';
import { connect } from 'react-redux';
import * as actions from './actions';
let createHandlers = function(dispatch) {
let onClick = function(node, data) {
dispatch(actions.nodeClicked(data))
};
return {
onClick,
// other handlers
};
}
class Controls extends Component {
constructor(props) {
super(props);
this.handlers = createHandlers(this.props.dispatch);
}
render() {
// pass this.handlers anywhere you'd like
}
}
export default connect()(Controls);
@Bastiani
Copy link
Author

DEVGRID Test, Rafael Campos de Bastiani

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