所以我从智能组件传递给哑组件的键列表越来越大?
还有什么其他方法可以简洁,快捷得多地编写此代码?
const mapStateToProps = (state) => {
let {keya, keyb, keyc, keyd, keye} = state.SomethingReducer.Table;
return {
keya: keya,
keyb: keyb,
keyc: keyc,
......
}
}
最佳答案
您可以使用ES6功能增强的对象文字。
const mapStateToProps = (state) => {
let {keya, keyb, keyc, keyd, keye} = state.SomethingReducer.Table;
return {
keya,
keyb,
keyc,
......
}
}