@solidjs/router 0.10.3 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -1
- package/dist/data/action.d.ts +1 -1
- package/dist/routers/components.d.ts +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -102,7 +102,35 @@ render(() => (
|
|
|
102
102
|
), document.getElementById("app"));
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
3.
|
|
105
|
+
3. Create a CatchAll Route (404 page)
|
|
106
|
+
|
|
107
|
+
We can create catchall routes for pages not found at any nested level of the router. We use `*` and optionally the name of a parameter to retrieve the rest of the path.
|
|
108
|
+
|
|
109
|
+
```jsx
|
|
110
|
+
import { render } from "solid-js/web";
|
|
111
|
+
import { Router, Route } from "@solidjs/router";
|
|
112
|
+
|
|
113
|
+
import Home from "./pages/Home";
|
|
114
|
+
import Users from "./pages/Users";
|
|
115
|
+
import NotFound from "./pages/404";
|
|
116
|
+
|
|
117
|
+
const App = props => (
|
|
118
|
+
<>
|
|
119
|
+
<h1>My Site with lots of pages</h1>
|
|
120
|
+
{props.children}
|
|
121
|
+
</>
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
render(() => (
|
|
125
|
+
<Router root={App}>
|
|
126
|
+
<Route path="/users" component={Users} />
|
|
127
|
+
<Route path="/" component={Home} />
|
|
128
|
+
<Route path="*404" component={NotFound} />
|
|
129
|
+
</Router>
|
|
130
|
+
), document.getElementById("app"));
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
4. Lazy-load route components
|
|
106
134
|
|
|
107
135
|
This way, the `Users` and `Home` components will only be loaded if you're navigating to `/users` or `/`, respectively.
|
|
108
136
|
|
|
@@ -848,6 +876,8 @@ The biggest changes are around removed APIs that need to be replaced.
|
|
|
848
876
|
|
|
849
877
|
This is no longer used and instead will use `props.children` passed from into the page components for outlets. This keeps the outlet directly passed from its page and avoids oddness of trying to use context across Islands boundaries. Nested `<Routes>` components inherently cause waterfalls and are `<Outlets>` themselves so they have the same concerns. We do not want to encourage the pattern and if you must do it you can always nest `<Router>`s with appropriate base path.
|
|
850
878
|
|
|
879
|
+
Keep in mind no `<Routes>` means the `<Router>` API is different. The `<Router>` acts as the `<Routes>` component and its children can only be `<Route>` components. Your top-level layout should go in the root prop of the router [as shown above](#configure-your-routes)
|
|
880
|
+
|
|
851
881
|
## `element` prop removed from `Route`
|
|
852
882
|
|
|
853
883
|
Related without Outlet component it has to be passed in manually. At which point the `element` prop has less value. Removing the second way to define route components to reduce confusion and edge cases.
|
package/dist/data/action.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { JSX } from "solid-js";
|
|
|
2
2
|
import { Submission } from "../types";
|
|
3
3
|
export type Action<T extends Array<any>, U> = (T extends [FormData] | [] ? JSX.SerializableAttributeValue : unknown) & ((...vars: T) => Promise<U>) & {
|
|
4
4
|
url: string;
|
|
5
|
-
with<A extends any[], B extends any[]>(this: (this: any, ...args: [...A, ...B]) => U
|
|
5
|
+
with<A extends any[], B extends any[]>(this: (this: any, ...args: [...A, ...B]) => Promise<U>, ...args: A): Action<B, U>;
|
|
6
6
|
};
|
|
7
7
|
export declare const actions: Map<string, Action<any, any>>;
|
|
8
8
|
export declare function useSubmissions<T extends Array<any>, U>(fn: Action<T, U>, filter?: (arg: T) => boolean): Submission<T, U>[] & {
|
|
@@ -6,12 +6,12 @@ export type BaseRouterProps = {
|
|
|
6
6
|
children?: JSX.Element | RouteDefinition | RouteDefinition[];
|
|
7
7
|
};
|
|
8
8
|
export declare const createRouterComponent: (router: RouterIntegration) => (props: BaseRouterProps) => JSX.Element;
|
|
9
|
-
export type RouteProps<S extends string> = {
|
|
9
|
+
export type RouteProps<S extends string, T = unknown> = {
|
|
10
10
|
path?: S | S[];
|
|
11
11
|
children?: JSX.Element;
|
|
12
|
-
load?: RouteLoadFunc
|
|
12
|
+
load?: RouteLoadFunc<T>;
|
|
13
13
|
matchFilters?: MatchFilters<S>;
|
|
14
|
-
component?: Component
|
|
14
|
+
component?: Component<RouteSectionProps<T>>;
|
|
15
15
|
metadata?: Record<string, any>;
|
|
16
16
|
};
|
|
17
|
-
export declare const Route: <S extends string>(props: RouteProps<S>) => JSX.Element;
|
|
17
|
+
export declare const Route: <S extends string>(props: RouteProps<S, unknown>) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"Ryan Turnquist"
|
|
7
7
|
],
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"version": "0.10.
|
|
9
|
+
"version": "0.10.5",
|
|
10
10
|
"homepage": "https://github.com/solidjs/solid-router#readme",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"prettier": "^2.7.1",
|
|
44
44
|
"rollup": "^3.7.5",
|
|
45
45
|
"solid-jest": "^0.2.0",
|
|
46
|
-
"solid-js": "^1.8.
|
|
46
|
+
"solid-js": "^1.8.7",
|
|
47
47
|
"typescript": "^5.2.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|