@@ -34,22 +34,18 @@ Firstly, you need to use our helper to allow your application to use asynchronou
34
34
``` jsx
35
35
import { withAsyncComponents } from ' react-async-component' ; // 👈
36
36
37
- // Declare your application as normal.
38
37
const app = < MyApp / > ;
39
38
40
- // Then provide it to our helper, which returns a Promise.
41
39
// 👇
42
- withAsyncComponents (app).then ((result ) => {
43
- // 👆 it resolves a "result" object
44
- const {
45
- // ❗️ We return a new version of your app that supports
46
- // asynchronous components. 💪
47
- appWithAsyncComponents
48
- } = result;
49
-
50
- // 🚀 render it!
51
- ReactDOM .render (appWithAsyncComponents, document .getElementById (' app' ));
52
- });
40
+ withAsyncComponents (app) // returns a Promise
41
+ .then ((result ) => {
42
+ ReactDOM .render (
43
+ // We return a new version of your app that supports
44
+ // asynchronous components.
45
+ result .appWithAsyncComponents , // 👈
46
+ document .getElementById (' app' )
47
+ );
48
+ });
53
49
```
54
50
55
51
Next up, let's make an asynchronous Component! We provide another helper for this.
@@ -58,8 +54,7 @@ Next up, let's make an asynchronous Component! We provide another helper for th
58
54
import { createAsyncComponent } from ' react-async-component' ; // 👈
59
55
60
56
const AsyncProduct = createAsyncComponent ({
61
- // Provide a function that will return a Promise that resolves
62
- // as your Component.
57
+ // Provide a function that returns a Promise to the target Component.
63
58
resolve : function resolveComponent () {
64
59
return new Promise (function (resolve ) {
65
60
// The Promise the resolves with a simple require of the
0 commit comments