'Cannot read property 'map' of undefined' when using connect with mapStateToProps

前端 未结 1 1908
半阙折子戏
半阙折子戏 2020-12-07 05:41

I am trying to display my state (users) in my react/redux functional component:

const Dumb = ({ users }) => {
  console.log(\'users\', users)
  return (
          


        
相关标签:
1条回答
  • 2020-12-07 06:08

    You aren't using the connected component while rendering and hence the props aren't available in the component

    const ConnectedDumb = connect(
      data,
      null
    )(Dumb);
    
    class Container extends React.Component {
      render() {
        return (
          <div>
            <ConnectedDumb />
          </div>
        );
      }
    }
    

    Working demo

    0 讨论(0)
提交回复
热议问题