You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -139,11 +139,11 @@ A promise that resolves in a `result` object. The `result` object will have the
139
139
-`state` (_Object_) : Only used on the "server" side of server side rendering applications. It represents the state of your async Components (i.e. which ones were rendered) so that the server can feed this information back to the client/browser.
140
140
-`STATE_IDENTIFIER` (_String_) : Only used on the "server" side of server side rendering applications. The identifier of the property you should bind the `state` object to on the `window` object.
Note: `System.import` is considered deprecated and will be replaced with `import`, but for now they can be used interchangeably (you may need a Babel plugin for the `import` syntax).
The below examples show off a full workflow of using the `createAsyncComponent` and `withAsyncComponents` helpers.
211
211
212
212
In all of our examples below we are going to be making use of the `System.import` API supported by Webpack v2 to do asynchronous resolution of our Components and create code split points.
213
213
214
-
#####Browser Only Application
214
+
#### Browser Only Application
215
215
216
216
This is how you would use `react-async-component` in a "browser only" React application.
217
217
@@ -261,7 +261,7 @@ withAsyncComponents(app)
261
261
});
262
262
```
263
263
264
-
#####Server Side Rendering Application
264
+
#### Server Side Rendering Application
265
265
266
266
This is how you would use `react-async-component` in a "server side rendering" React application.
###Important Information for using in Server Side Rendering Applications
366
+
## Important Information for using in Server Side Rendering Applications
367
367
368
368
This library is built to be used within server side rendering (SSR) applications, however, there are some important points/tips we would like to raise with you so that you can design your application components in an efficient and effective manner.
369
369
370
-
####SSR AsyncComponent Resolution Process
370
+
### SSR AsyncComponent Resolution Process
371
371
372
372
It is worth us highlighting exactly how we go about resolving and rendering your `AsyncComponent` instances on the server. This knowledge will help you become aware of potential issues with your component implementations as well as how to effectively use our provided configuration properties to create more efficient implementations.
373
373
374
374
When running `react-async-component` on the server the helper has to walk through your react element tree (depth first i.e. top down) in order to discover all the AsyncComponent instances and resolve them in preparation for when you call the `ReactDOM.renderToString`. As it walks through the tree it has to call the `componentWillMount` method on your Components and then the `render` methods so that it can get back the child react elements for each Component and continue walking down the element tree. When it discovers an `AsyncComponent` instance it will first resolve the Component that it refers to and then it will continue walking down it's child elements (unless you set the configuration for your `AsyncComponent` to not allow this) in order to try and discover any nested `AsyncComponent` instances. It continues doing this until it exhausts your element tree.
375
375
376
376
Although this operation isn't as expensive as an actual render as we don't generate the DOM it can still be quite wasteful if you have a deep tree. Therefore we have provided a set of configuration values that allow you to massively optimise this process. See the next section below.
377
377
378
-
####SSR Performance Optimisation
378
+
### SSR Performance Optimisation
379
379
380
380
As discussed in the ["SSR AsyncComponent Resolution Process"](#ssr-asyncComponent-resolution-process) section above it is possible to have an inefficient implementation of your async Components. Therefore we introduced a new configuration object property for the `createAsyncComponent` helper, called `ssrMode`, which provides you with a mechanism to optimise the configuration of your async Component instances.
0 commit comments