我知道像foo(bar( baz) )这样的东西可以重写为compose(foo,bar,baz)。然而,现实生活中的例子呢?例如,我可能有:
export default {
loadData,
component: connect(mapStateToProps, {
actionCreator1,
actionCreator2
})(requireAuth(showToggle({ChildComponent: aComponentOfMine, anotherField: `becauseStringsAreCool`})))是否可以使用compose重构组件值?
发布于 2018-01-21 04:42:28
示例中的component值可以重写为使用compose,如下所示:
const buildComponent = compose(
connect(mapStateToProps, {
actionCreator1,
actionCreator2
}),
requireAuth,
showToggle
)
export default {
loadData,
component: buildComponent({
ChildComponent: aComponentOfMine,
anotherField: `becauseStringsAreCool`
})
}https://stackoverflow.com/questions/48359526
复制相似问题