React-redux connect() cannot wrap component defined as a class extending React.Component

前端 未结 2 1569
离开以前
离开以前 2021-02-19 05:59

I may be missing something, but I can\'t find any example where connect() wraps a component defined as a class (extending React.Component), it always

2条回答
  •  北海茫月
    2021-02-19 06:54

    you actually are correctly wrapping your component class in connect(). Your problem is elsewhere, in routes/Home/index.js:

    import HomeContainer from './containers/HomeContainer'
    
    export default (store) => {
      component : HomeContainer(store)
    }
    

    the default export of HomeContainer is the higher-order class returned by connect. You're then trying to use HomeContainer as a function here, just like your console error says:

        HomeContainer(store)
    

    .

提交回复
热议问题