Skip to content

Commit d4d38aa

Browse files
committed
Merge pull request #974 from DelvarWorld/copy-changes
Updating legacy copy to replace fetchData with @asyncConnect
2 parents 2fd5057 + 39a0744 commit d4d38aa

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ We also spit out the `redux` state into a global `window.__data` variable in the
106106

107107
#### Server-side Data Fetching
108108

109-
We ask `react-router` for a list of all the routes that match the current request and we check to see if any of the matched routes has a static `fetchData()` function. If it does, we pass the redux dispatcher to it and collect the promises returned. Those promises will be resolved when each matching route has loaded its necessary data from the API server.
109+
The [redux-async-connect](https://www.npmjs.com/package/redux-async-connect) package exposes an API to return promises that need to be fulfilled before a route is rendered. It exposes a `<ReduxAsyncConnect />` container, which wraps our render tree on both [server](https://github.com/erikras/react-redux-universal-hot-example/blob/master/src/server.js) and [client](https://github.com/erikras/react-redux-universal-hot-example/blob/master/src/client.js). More documentation is available on the [redux-async-connect](https://www.npmjs.com/package/redux-async-connect) page.
110110

111111
#### Client Side
112112

src/containers/Home/Home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default class Home extends Component {
112112
<dd>
113113
The <Link to="/widgets">Widgets page</Link> demonstrates how to fetch data asynchronously from
114114
some source that is needed to complete the server-side rendering. <code>Widgets.js</code>'s
115-
<code>fetchData()</code> function is called before the widgets page is loaded, on either the server
115+
<code>asyncConnect()</code> function is called before the widgets page is loaded, on either the server
116116
or the client, allowing all the widget data to be loaded and ready for the page to render.
117117
</dd>
118118
<dt>Data loading errors</dt>

src/containers/Widgets/Widgets.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export default class Widgets extends Component {
5757
<p>
5858
If you hit refresh on your browser, the data loading will take place on the server before the page is returned.
5959
If you navigated here from another page, the data was fetched from the client after the route transition.
60-
This uses the static method <code>fetchDataDeferred</code>. To block a route transition until some data is loaded, use <code>fetchData</code>.
60+
This uses the decorator method <code>@asyncConnect</code> with the <code>deferred: true</code> flag. To block
61+
a route transition until some data is loaded, remove the <code>deffered: true</code> flag.
6162
To always render before loading data, even on the server, use <code>componentDidMount</code>.
6263
</p>
6364
<p>

0 commit comments

Comments
 (0)