brocoders / redux-async-connect

It allows you to request async data, store them in redux state and connect them to your react component.
645 stars 103 forks source link

asyncItems.map is not a function #48

Open bartolkaruza opened 8 years ago

bartolkaruza commented 8 years ago

I'm running into an issue with the asyncConnect decorator on the 1.0.0-rc2 version. The exact same decorator was working without issue on 0.13. If I'm reading this commit correctly, we have to pass an array instead of an object now?

The error:

/Users/bartolkaruza/Development/Projects/dmm/dmm-web/node_modules/redux-async-connect/lib/asyncConnect.js:116
[1]   return asyncItems.map(function (item) {
[1]                     ^
[1] 
[1] TypeError: asyncItems.map is not a function
[1]     at wrapWithDispatch (/Users/bartolkaruza/Development/Projects/dmm/dmm-web/node_modules/redux-async-connect/lib/asyncConnect.js:116:21)

The decorator that causes the error;

@asyncConnect({
  segments: (params, helpers) => {
    return Promise.resolve();
  }
})
class Segments extends Component {

  render() {
    console.log(this.props.segments);
    return (
        <div>
          <h1>
            Segments
          </h1>
        </div>
    )
  }
}
sars commented 8 years ago

@bartolkaruza, Hey,

please see example here: https://github.com/erikras/react-redux-universal-hot-example/pull/928/files

Keats commented 8 years ago

Does it still work as static method in 1.0 or are decorators mandatory? I'm getting Uncaught TypeError: asyncItems.reduce is not a function because asyncItems is a function if it's a static method

marpe commented 7 years ago

So the example in the readme is outdated? I'm running into the same issue with rc4

xgqfrms-GitHub commented 7 years ago

https://github.com/xgqfrms-GitHub/rraio/issues/2

The .map function is only available on array.