Commit 89a2ec97 by hfpp2012 yinsigan

bindActionCreators

1 parent 5dd3a784
...@@ -4,7 +4,8 @@ import ReactAddonsUpdate from 'react-addons-update' ...@@ -4,7 +4,8 @@ import ReactAddonsUpdate from 'react-addons-update'
import autobind from 'autobind-decorator' import autobind from 'autobind-decorator'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { cloneElement, deleteLastElement } from '../actions/headergroup'; import { bindActionCreators } from 'redux'
import * as HeaderGroupActions from '../actions/headergroup'
@autobind @autobind
class ElementGroup extends React.Component { class ElementGroup extends React.Component {
...@@ -19,13 +20,13 @@ class ElementGroup extends React.Component { ...@@ -19,13 +20,13 @@ class ElementGroup extends React.Component {
} }
render() { render() {
const { elements, cloneElement, deleteLastElement } = this.props const { elements, actions } = this.props
return ( return (
<div> <div>
{ {
elements.map(function(element) { elements.map(function(element) {
return ( return (
<Element meta_element={ element } key={ "key_" + element.id } id={ element.id } name={ element.name } initialPos={ element.initialPos } target_type={ element.target_type } handleCloneElement={ cloneElement } handleDeleteElement={ this.deleteElement } handleDeleteLastElement={ deleteLastElement } /> <Element meta_element={ element } key={ "key_" + element.id } id={ element.id } name={ element.name } initialPos={ element.initialPos } target_type={ element.target_type } handleCloneElement={ actions.cloneElement } handleDeleteElement={ this.deleteElement } handleDeleteLastElement={ actions.deleteLastElement } />
) )
}.bind(this)) }.bind(this))
} }
...@@ -39,12 +40,7 @@ const mapStateToProps = (state, ownProps) => ({ ...@@ -39,12 +40,7 @@ const mapStateToProps = (state, ownProps) => ({
}) })
const mapDispatchToProps = (dispatch, ownProps) => ({ const mapDispatchToProps = (dispatch, ownProps) => ({
cloneElement: (element) => { actions: bindActionCreators(HeaderGroupActions, dispatch)
dispatch(cloneElement(element))
},
deleteLastElement: () => {
dispatch(deleteLastElement())
}
}) })
export default connect( export default connect(
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!