javascript 使用connect.js绑定动作的对象文字简写

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 使用connect.js绑定动作的对象文字简写相关的知识,希望对你有一定的参考价值。

import {connect} from "react-redux";
import {action1, action2} from "myActions";


const MyComponent = (props) => (
    <div>
        <button onClick={props.action1}>Do first action</button>
        <button onClick={props.action2}>Do second action</button>
    </div>
)

// Passing an object full of actions will automatically run each action 
// through the bindActionCreators utility, and turn them into props

export default connect(null, {action1, action2})(MyComponent);

以上是关于javascript 使用connect.js绑定动作的对象文字简写的主要内容,如果未能解决你的问题,请参考以下文章