Home Can I remove mapStateToProps from my component having only mapDispatchToProps?
Reply: 0

Can I remove mapStateToProps from my component having only mapDispatchToProps?

user737
1#
user737 Published in July 23, 2018, 1:41 pm

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 remove mapStateToProps completely and use connect like -

export default connect(mapDispatchToProps)(Application);

then getting error - Uncaught (in promise) TypeError: dispatch is not a function.

Is it mandatory to keep an empty mapStateToProps.

const mapStateToProps = state =>
    ({

    })

Please clarify .

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.360983 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO