2

I'm unable to get my connect()() component to map state to props and then destructure my this.props to connect to my redux store.

I get a console error that const {items} = this.props; shows that items is undefined.

Attached is a gist of my code.

https://gist.github.com/ericchen0121/6bc0654563fa71ab04dd69e0bfeb6668

Eric Chen
  • 63
  • 7
  • have you tried console logging `reduxState.items` in `mapStateToProps` function? Also try logging `this.props.items` in `componentDidMount` of `connectedItems` class. `items` props might be empty. – Noushad Mar 25 '17 at 08:01
  • Have you tried modifying your `createStore`? Based on the docs the 2nd param should be a [reducer-like](http://redux.js.org/docs/api/createStore.html) structure but you passed in the enhancers? – JohnnyQ Mar 25 '17 at 08:15
  • I've tried running this code on my machine and store is created properly. `reduxState.items` is not empty, I checked it in Redux Dev Tools. I'm going to look into this more in the evening. – vasekhlav Mar 25 '17 at 11:19

1 Answers1

2

I found out what the bug is. In your App.js file you want to import Items container using

import { Items } from '../containers/Items'

when it should actually be like this:

import Items from '../containers/Items'.

Here is a good answer regarding import/export in ES6.

Community
  • 1
  • 1
vasekhlav
  • 419
  • 4
  • 12