|
1 | | -import { lazy, LocationProvider, ErrorBoundary, Router, Route } from 'fullsoak/preact-iso'; |
| 1 | +import { |
| 2 | + ErrorBoundary, |
| 3 | + lazy, |
| 4 | + LocationProvider, |
| 5 | + Route, |
| 6 | + Router, |
| 7 | +} from "preact-iso"; |
2 | 8 |
|
3 | 9 | // Synchronous |
4 | | -import { Home } from './routes/Home.tsx'; |
5 | | -import { Profiles } from './routes/Profiles.tsx'; |
| 10 | +import { Home } from "./routes/Home.tsx"; |
| 11 | +import { Profiles } from "./routes/Profiles.tsx"; |
6 | 12 |
|
7 | 13 | // Asynchronous (throws a promise) |
8 | | -const Profile = lazy(() => import('./routes/Profile.tsx').then(cmp => cmp.Profile)); |
9 | | -const NotFound = lazy(() => import('./routes/_404.tsx').then(cmp => cmp.NotFound)); |
| 14 | +const Profile = lazy(() => |
| 15 | + import("./routes/Profile.tsx").then((cmp) => cmp.Profile) |
| 16 | +); |
| 17 | +const NotFound = lazy(() => |
| 18 | + import("./routes/_404.tsx").then((cmp) => cmp.NotFound) |
| 19 | +); |
10 | 20 |
|
11 | | -type AppProps = { url: string } |
| 21 | +type AppProps = { url: string }; |
12 | 22 |
|
13 | 23 | export const MyRouteAwareComponent = ({ url }: AppProps) => ( |
14 | | - <LocationProvider url={url} scope="/app"> |
15 | | - <ErrorBoundary> |
16 | | - <Router> |
17 | | - <Home path="/app" /> |
18 | | - {/* Alternative dedicated route component for better TS support */} |
19 | | - <Route path="/app/profiles" component={Profiles} /> |
20 | | - <Route path="/app/profiles/:id" component={() => <Profile blah="foo" />} /> |
21 | | - {/* `default` prop indicates a fallback route. Useful for 404 pages */} |
22 | | - <NotFound default /> |
23 | | - </Router> |
24 | | - </ErrorBoundary> |
25 | | - </LocationProvider> |
| 24 | + <LocationProvider url={url} scope="/app"> |
| 25 | + <ErrorBoundary> |
| 26 | + <Router> |
| 27 | + <Home path="/app" /> |
| 28 | + {/* Alternative dedicated route component for better TS support */} |
| 29 | + <Route path="/app/profiles" component={Profiles} /> |
| 30 | + <Route |
| 31 | + path="/app/profiles/:id" |
| 32 | + component={() => <Profile blah="foo" />} |
| 33 | + /> |
| 34 | + {/* `default` prop indicates a fallback route. Useful for 404 pages */} |
| 35 | + <NotFound default /> |
| 36 | + </Router> |
| 37 | + </ErrorBoundary> |
| 38 | + </LocationProvider> |
26 | 39 | ); |
0 commit comments