Commit 89a2ec97 by hfpp2012 yinsigan

bindActionCreators

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