Skip to content

Commit 3bd3473

Browse files
Merge branch 'main' into update/use-submission
2 parents 7b9a220 + cae2e43 commit 3bd3473

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed
+26-26
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
---
2-
title: Catch-all routes
3-
---
4-
5-
Catch-all routes are used to match any URL that does not match any other route in the application.
6-
This is useful for displaying a 404 page or redirecting to a specific route when a user enters an invalid URL.
7-
8-
To create a catch-all route, place a route with a asteriks `*` as the path at the end of the route list.
9-
Optionally, you can name the parameter to access the unmatched part of the URL.
10-
11-
```jsx
12-
import { Router, Route } from "@solidjs/router";
13-
14-
import Home from "./Home";
15-
import About from "./About";
16-
import NotFound from "./NotFound";
17-
18-
const App = () => (
19-
<Router>
20-
<Route path="/home" element={<Home />} />
21-
<Route path="/about" element={<About />} />
22-
<Route path="*404" element={<NotFound />} />
23-
</Router>
24-
);
25-
```
26-
1+
---
2+
title: Catch-all routes
3+
---
4+
5+
Catch-all routes are used to match any URL that does not match any other route in the application.
6+
This is useful for displaying a 404 page or redirecting to a specific route when a user enters an invalid URL.
7+
8+
To create a catch-all route, place a route with a asteriks `*` as the path at the end of the route list.
9+
Optionally, you can name the parameter to access the unmatched part of the URL.
10+
11+
```jsx
12+
import { Router, Route } from "@solidjs/router";
13+
14+
import Home from "./Home";
15+
import About from "./About";
16+
import NotFound from "./NotFound";
17+
18+
const App = () => (
19+
<Router>
20+
<Route path="/home" component={Home} />
21+
<Route path="/about" component={About} />
22+
<Route path="*404" component={NotFound} />
23+
</Router>
24+
);
25+
```
26+
2727
Now, if a user navigates to a URL that does not match `/home` or `/about`, the `NotFound` component will be rendered.

src/routes/solid-router/concepts/layouts.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ render(
3030
() => (
3131
<Router root={Layout}>
3232
<Route path="/" component={Home} />
33-
<Route path="/hello-world" component={<div>Hello world!</div>} />
34-
33+
<Route path="/hello-world" component={() => <div>Hello world!</div>} />
3534
</Router>
3635
),
3736
document.getElementById("app")

0 commit comments

Comments
 (0)