我想知道这两个代码块之间的区别是什么。他们的工作方式是否有所不同,因为我没有在某处获得某种语法,或者它们是否根本不同?
没有装饰者我得到:
@connect(
state => ({
notes: state.notes,
activeNote: state.activeNote,
}),
dispatch => ({
actions: bindActionCreators(NoteActions, dispatch)
})
)
export default class Main extends Component {
static propTypes = {
notes: PropTypes.array.isRequired,
activeNote: PropTypes.object,
// actions: PropTypes.object.isRequired,
};
render() {
const { notes, activeNote, NoteActions } = this.props;
return (
<div className={style.normal}>
<MainSection actions={NoteActions} />
</div>
);
}
}
使用装饰器
const mapStateToProps = function(state) {
return {
notes: state.notes,
activeNote: state.activeNote,
};
};
const mapDispatchToProps = function (dispatch) {
return bindActionCreators({
NoteActions
}, dispatch);
};
export default connect(mapStateToProps, mapDispatchToProps)(Main);
没有装饰者
var pairrdd = sc.parallelize(List((1,2),(3,4),(3,6)))
var pairrdd2 = sc.parallelize(List((3,9)))