如何将 'withRedux' 包装器与 'compose' 结合起来

How do you combine 'withRedux' wrapper with 'compose'

我有一个用于 next.js 应用程序的 redux 包装器。 如何将 compose 与此类包装器结合使用?

export default withRedux(initStore, null, mapDispatchToProps)(App)

export default compose(
    connect(mapStateToProps, mapDispatchToProps),
    DropTarget(NativeTypes.FILE, dustbinTarget, (connect, monitor) => ({
        connectDropTarget: connect.dropTarget(),
        isOver: monitor.isOver(),
        canDrop: monitor.canDrop(),
    }))
)(DustBin);

如果您的包装器遵循标准的 HOC 约定(即返回丰富组合组件的函数),您所要做的就是:

export default compose(
    withRedux(initStore, null, mapDispatchToProps),
    DropTarget(NativeTypes.FILE, dustbinTarget, (connect, monitor) => ({
        connectDropTarget: connect.dropTarget(),
        isOver: monitor.isOver(),
        canDrop: monitor.canDrop(),
    }))
)(DustBin);