Skip to content

Commit 65710be

Browse files
committed
update README.md - add lazyloading section
1 parent 8e3b334 commit 65710be

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,36 @@ These routes then need to be added to the routes file for the parent tools/utils
272272
Simply adding the routes to one of thes files above will register the tool/util
273273
with the application and will display the new component.
274274

275+
### Lazy loading and code splitting
276+
277+
When loading a route component, please use the `lazyLoad()` method defined in the application lib.
278+
279+
| param | description|
280+
| ----- | ---------- |
281+
| `moduleImport: () => Promise<any>` | Function which imports the desired module |
282+
| `namedExport?: string` | The name of the exported module (if the module has named exports) |
283+
284+
Eg:
285+
```
286+
// Lazy load the WelcomePage component
287+
const WelcomePage: LazyLoadedComponent = lazyLoad(() => import('./welcome'), 'WelcomePage')
288+
...
289+
// Use the component as route element
290+
export const learnRoutes: Array<PlatformRoute> = [
291+
{
292+
children: [
293+
{
294+
children: [],
295+
element: <WelcomePage />,
296+
...
297+
},
298+
...
299+
]
300+
}
301+
]
302+
```
303+
304+
275305
### Platform Route
276306

277307
The PlatformRoute model has several useful options:

0 commit comments

Comments
 (0)