Skip to content

Commit 4430b12

Browse files
committed
Updates docs.
1 parent da43b5b commit 4430b12

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ const AsyncProduct = createAsyncComponent({
2626
- [Creating Async Components](#creating-async-components)
2727
- [Simple](#simple)
2828
- [With Loading Component](#with-loading-component)
29-
- [Webpack 1/2 `require.ensure` Code Splitting](#webpack-12-require.ensure-code-splitting)
30-
- [Webpack 2 `import` / `System.import` Code Splitting](#webpack-2-import-system.import-code-splitting)
29+
- [Webpack 1/2 `require.ensure` Code Splitting](#webpack-12-requireensure-code-splitting)
30+
- [Webpack 2 `import` / `System.import` Code Splitting](#webpack-2-import--systemimport-code-splitting)
3131
- [Defer Loading to the Client/Browser](#defer-loading-to-the-clientbrowser)
3232
- [End to End Examples](#end-to-end-examples)
3333
- [Browser Only Application](#browser-only-application)
3434
- [Server Side Rendering Application](#server-side-rendering-application)
35-
- [Important Information for using in Server Side Rendering Applications](#important-information-for-using in-server-side-rendering-applications)
36-
- [SSR AsyncComponent Resolution Process](#ssr-asyncComponent-resolution-process)
35+
- [Important Information for using in Server Side Rendering Applications](#important-information-for-using-in-server-side-rendering-applications)
36+
- [SSR AsyncComponent Resolution Process](#ssr-asynccomponent-resolution-process)
3737
- [SSR Performance Optimisation](#ssr-performance-optimisation)
3838
- [Caveats](#caveats)
3939
- [FAQs](#faqs)
@@ -139,11 +139,11 @@ A promise that resolves in a `result` object. The `result` object will have the
139139
- `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.
140140
- `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.
141141

142-
### Examples
142+
## Examples
143143

144-
#### Creating Async Components
144+
### Creating Async Components
145145

146-
##### Simple
146+
#### Simple
147147

148148
```jsx
149149
const AsyncProduct = createAsyncComponent({
@@ -155,7 +155,7 @@ const AsyncProduct = createAsyncComponent({
155155
<AsyncProduct productId={1} />
156156
```
157157

158-
##### With Loading Component
158+
#### With Loading Component
159159

160160
```jsx
161161
const AsyncProduct = createAsyncComponent({
@@ -168,7 +168,7 @@ const AsyncProduct = createAsyncComponent({
168168
<AsyncProduct productId={1} />
169169
```
170170

171-
##### Webpack 1/2 `require.ensure` Code Splitting
171+
#### Webpack 1/2 `require.ensure` Code Splitting
172172

173173
```jsx
174174
const AsyncProduct = createAsyncComponent({
@@ -182,7 +182,7 @@ const AsyncProduct = createAsyncComponent({
182182
<AsyncProduct productId={1} />
183183
```
184184

185-
##### Webpack 2 `import` / `System.import` Code Splitting
185+
#### Webpack 2 `import` / `System.import` Code Splitting
186186

187187
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).
188188

@@ -194,7 +194,7 @@ const AsyncProduct = createAsyncComponent({
194194
<AsyncProduct productId={1} />
195195
```
196196

197-
##### Defer Loading to the Client/Browser
197+
#### Defer Loading to the Client/Browser
198198

199199
i.e. The component won't be resolved and rendered in a server side rendering execution.
200200

@@ -205,13 +205,13 @@ const AsyncProduct = createAsyncComponent({
205205
});
206206
```
207207

208-
#### End to End Examples
208+
### End to End Examples
209209

210210
The below examples show off a full workflow of using the `createAsyncComponent` and `withAsyncComponents` helpers.
211211

212212
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.
213213

214-
##### Browser Only Application
214+
#### Browser Only Application
215215

216216
This is how you would use `react-async-component` in a "browser only" React application.
217217

@@ -261,7 +261,7 @@ withAsyncComponents(app)
261261
});
262262
```
263263

264-
##### Server Side Rendering Application
264+
#### Server Side Rendering Application
265265

266266
This is how you would use `react-async-component` in a "server side rendering" React application.
267267

@@ -363,19 +363,19 @@ export default function expressMiddleware(req, res, next) {
363363
}
364364
```
365365

366-
### Important Information for using in Server Side Rendering Applications
366+
## Important Information for using in Server Side Rendering Applications
367367

368368
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.
369369

370-
#### SSR AsyncComponent Resolution Process
370+
### SSR AsyncComponent Resolution Process
371371

372372
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.
373373

374374
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.
375375

376376
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.
377377

378-
#### SSR Performance Optimisation
378+
### SSR Performance Optimisation
379379

380380
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.
381381

0 commit comments

Comments
 (0)