Can I remove mapStateToProps from my component that only has mapDispatchToProps?

I don't need mapStateToProps in my component, but I need mapDispatchToProps -

const mapDispatchToProps = dispatch =>
    ({
        myCallBack(passFunc, passDirFunc) {
            dispatch(
                actions.setSideNavAction(passFunc, passDirFunc)
            )
        }
    }) 

If I completely remove mapStateToProps and use connect as -

export default connect(mapDispatchToProps)(Application);

then get an error - unclean (in promise) TypeError: sending is not a function.

Be sure to keep empty mapStateToProps.

const mapStateToProps = state =>
    ({

    })

Please clarify.

+4
source share
1 answer

You can simply pass nullin connect:

export default connect(null, mapDispatchToProps)(Application);
+8
source

Source: https://habr.com/ru/post/1674185/


All Articles