Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The sample client code in usage doesn't work. #109

Open
shilei812 opened this issue Apr 28, 2017 · 2 comments
Open

The sample client code in usage doesn't work. #109

shilei812 opened this issue Apr 28, 2017 · 2 comments

Comments

@shilei812
Copy link

shilei812 commented Apr 28, 2017

https://codesandbox.io/s/gL3zJKv9Z

`import { Router,Route , browserHistory } from 'react-router';
import { ReduxAsyncConnect, asyncConnect, reducer as reduxAsyncConnect } from 'redux-async-connect'
import React from 'react'
import { render } from 'react-dom'
import { createStore, combineReducers } from 'redux';
import {Provider} from 'react-redux';
// 1. Connect your data, similar to react-redux @connect
@asyncConnect({
lunch: (params, helpers) => Promise.resolve({id: 1, name: 'Borsch'})
})
class App extends React.Component {
render() {
// 2. access data as props
const lunch = this.props.lunch
return (

{lunch.name}

)
}
}

// 3. Connect redux async reducer
const store = createStore(combineReducers({reduxAsyncConnect}), window.__data);

// 4. Render Router with ReduxAsyncConnect middleware
render((

<Router render={(props) => <ReduxAsyncConnect {...props}/>} history={browserHistory}>



), document.getElementById('root'))`

result

Error in index.js:
TypeError: asyncItems.map is not a function
OPEN MODULE

@lnikell
Copy link

lnikell commented May 5, 2017

Have the same issue

@tomCollinson
Copy link

.map only works on arrays which the code in @asyncconnect isn't - it's an object. I'm not using this at the moment but from memory you need to add an array like this:

@asyncconnect([{ lunch: (params, helpers) => Promise.resolve({id: 1, name: 'Borsch'}) }])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants