Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 16e435c

Browse files
committed
Update README.md file
1 parent 934e57b commit 16e435c

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,29 @@ export default function configureStore(initialState) {
5555
Decorate your route components with `withFetch()` and provide a function that returns a promise that is settled after the application state is updated with the data required before rendering them.
5656

5757
```js
58-
import React, { Component } from 'react';
58+
import React from 'react';
59+
import { compose } from 'redux';
5960
import { connect } from 'react-redux';
6061
import { withFetch } from '@flowio/redux-fetch';
61-
import { fetchThings } from './app/actions';
62+
import { fetchOneThing, fetchTwoThings } from './app/actions';
6263
import { getThings } from './app/selectors';
64+
import { ThingComponent } from './app/components';
6365

64-
function fetchAsyncState(dispatch /* getState, routerState */) {
65-
return dispatch(fetchThings());
66-
}
66+
const fetchAsyncState = (dispatch/*, getState, routerState */) => Promise.all([
67+
dispatch(fetchOneThing()),
68+
dispatch(fetchTwoThings()),
69+
]);
6770

68-
function mapStateToProps(state) {
69-
return {
70-
things: getThings(state),
71-
};
72-
}
71+
const mapStateToProps = (state) => ({
72+
things: getThings(state),
73+
});
7374

74-
@withFetch(fetchAsyncState)
75-
@connect(mapStateToProps)
76-
export default class Container extends Component {
77-
/* ... */
78-
}
75+
const enhance = compose(
76+
withFetch(fetchAsyncState),
77+
connect(mapStateToProps),
78+
);
79+
80+
export default enhance(ThingComponent);
7981
```
8082

8183
### Configure server-side rendering

0 commit comments

Comments
 (0)