Skip to content

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

Open
@shilei812

Description

@shilei812

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions