cocoPuffs
cocoPuffs

Reputation: 669

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

I have a redux wrapper that I'm using to work with a next.js app. How do I combine compose with this type of wrapper?

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

and

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

Upvotes: 0

Views: 180

Answers (1)

saimeunt
saimeunt

Reputation: 22696

If your wrapper adheres to the standard HOC convention (ie. a function returning an enriched composed component), all you have to do is:

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

Upvotes: 1

Related Questions