diff --git a/README.md b/README.md index d9467523..b4088c08 100644 --- a/README.md +++ b/README.md @@ -61,25 +61,26 @@ You can also make params optional by adding a `?` to it. ### Lazy Loading -Lazy loading (code splitting) with `preact-router` can be implemented easily using the [AsyncRoute](https://www.npmjs.com/package/preact-async-route) module: - +Lazy loading (code splitting) with `preact-router` can be implemented using the `lazy`-component. ```js -import AsyncRoute from 'preact-async-route'; - - - import('./friends').then(module => module.default) } - /> - import('./friend').then(module => module.default) } - loading={ () =>
loading...
} - /> -
+import { lazy, Suspense } from "preact/compat"; +import { Router } from "preact-router"; + +const Home = lazy(() => import("./home")); + +function App() { + return ( +
+ Loading...
}> + + + + + + ); +} ``` - ### Active Matching & Links `preact-router` includes an add-on module called `match` that lets you wire your components up to Router changes.