Reputation: 257
I am trying to learn React with Redux. As a starter kit I picked "react-redux-universal-hot-example"
I am trying to create a new page that shows some data. I followed Widgets page closely, but for some reason my page shows no data.
Here what I have done:
I created a new container: Outfits.js
Added action to API folder: load.js
added Redux module outfits.js
It must be something relatively small that I am missing but I can't figure out what.
The whole project with my changes is here: https://github.com/zunperior/wear4cast
Upvotes: 0
Views: 549
Reputation: 2302
The @asyncConnect
decorator doesn't replace the @connect
decorator. You are using asyncConnect to load your data when needed, but there is nothing connecting the data in your store to your component. You need to uncomment importing connect on line 3 and then use it to connect your props to the redux store.
@asyncConnect([{
deferred: true,
promise: ({store: {dispatch, getState}}) => {
if (!isLoaded(getState())) {
return dispatch(loadOutfits());
}
}
}])
@connect(
state => ({
outfits: state.outfits.data,
error: state.outfits.error,
loading: state.outfits.loading
}),
{}
)
export default class Outfits extends Component {
static propTypes = {
outfits: PropTypes.string,
error: PropTypes.string,
loading: PropTypes.bool
};
// ...
}
Upvotes: 1