Only bind action creators once

This commit is contained in:
Chi Vinh Le
2017-04-03 14:41:12 +07:00
parent 512405b3f0
commit 24aba5084b
+8 -4
View File
@@ -40,6 +40,7 @@ import NewCount from './NewCount';
class Embed extends Component {
state = {activeTab: 0, showSignInDialog: false, activeReplyBox: ''};
pluginActions = {}
changeTab = (tab) => {
@@ -66,6 +67,11 @@ class Embed extends Component {
removeCommentTag: React.PropTypes.func,
}
constructor(props) {
super(props);
this.pluginActions = bindActionCreators(actions.pluginActions, props.dispatch);
}
componentDidMount () {
pym.sendMessage('childReady');
}
@@ -122,14 +128,12 @@ class Embed extends Component {
* Plugins Section
*
*/
const {dispatch, state, ...currentProps} = this.props;
const {pluginActions} = actions;
let boundActionCreators = bindActionCreators(pluginActions, dispatch);
const {state, ...currentProps} = this.props;
const pluginProps = {
state,
context: currentProps,
actions: boundActionCreators
actions: this.pluginActions,
};
return (