Skip to content

Commit 189b484

Browse files
committed
simple.router -> browser_router
1 parent 332ca75 commit 189b484

File tree

14 files changed

+40
-47
lines changed

14 files changed

+40
-47
lines changed

docs/examples/python/basic-routing-more-routes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from reactpy import component, html, run
2-
3-
from reactpy_router import route, simple
2+
from reactpy_router import browser_router, route
43

54

65
@component
76
def root():
8-
return simple.router(
7+
return browser_router(
98
route("/", html.h1("Home Page 🏠")),
109
route("/messages", html.h1("Messages 💬")),
1110
route("*", html.h1("Missing Link 🔗‍💥")),

docs/examples/python/basic-routing.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from reactpy import component, html, run
2-
3-
from reactpy_router import route, simple
2+
from reactpy_router import browser_router, route
43

54

65
@component
76
def root():
8-
return simple.router(
7+
return browser_router(
98
route("/", html.h1("Home Page 🏠")),
109
route("*", html.h1("Missing Link 🔗‍💥")),
1110
)

docs/examples/python/nested-routes.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import TypedDict
22

33
from reactpy import component, html, run
4-
from reactpy_router import link, route, simple
4+
from reactpy_router import browser_router, link, route
55

66
message_data: list["MessageDataType"] = [
77
{"id": 1, "with": ["Alice"], "from": None, "message": "Hello!"},
@@ -17,7 +17,7 @@
1717

1818
@component
1919
def root():
20-
return simple.router(
20+
return browser_router(
2121
route("/", home()),
2222
route(
2323
"/messages",
@@ -40,10 +40,7 @@ def home():
4040

4141
@component
4242
def all_messages():
43-
last_messages = {
44-
", ".join(msg["with"]): msg
45-
for msg in sorted(message_data, key=lambda m: m["id"])
46-
}
43+
last_messages = {", ".join(msg["with"]): msg for msg in sorted(message_data, key=lambda m: m["id"])}
4744
return html.div(
4845
html.h1("All Messages 💬"),
4946
html.ul(

docs/examples/python/route-links.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from reactpy import component, html, run
2-
3-
from reactpy_router import link, route, simple
2+
from reactpy_router import browser_router, link, route
43

54

65
@component
76
def root():
8-
return simple.router(
7+
return browser_router(
98
route("/", home()),
109
route("/messages", html.h1("Messages 💬")),
1110
route("*", html.h1("Missing Link 🔗‍💥")),

docs/examples/python/route-parameters.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import TypedDict
22

33
from reactpy import component, html, run
4-
from reactpy_router import link, route, simple
4+
from reactpy_router import browser_router, link, route
55
from reactpy_router.core import use_params
66

77
message_data: list["MessageDataType"] = [
@@ -18,7 +18,7 @@
1818

1919
@component
2020
def root():
21-
return simple.router(
21+
return browser_router(
2222
route("/", home()),
2323
route(
2424
"/messages",
@@ -39,10 +39,7 @@ def home():
3939

4040
@component
4141
def all_messages():
42-
last_messages = {
43-
", ".join(msg["with"]): msg
44-
for msg in sorted(message_data, key=lambda m: m["id"])
45-
}
42+
last_messages = {", ".join(msg["with"]): msg for msg in sorted(message_data, key=lambda m: m["id"])}
4643
return html.div(
4744
html.h1("All Messages 💬"),
4845
html.ul(

docs/examples/python/use-params.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from reactpy import component, html
2-
3-
from reactpy_router import link, route, simple, use_params
2+
from reactpy_router import browser_router, link, route, use_params
43

54

65
@component
@@ -11,7 +10,7 @@ def user():
1110

1211
@component
1312
def root():
14-
return simple.router(
13+
return browser_router(
1514
route(
1615
"/",
1716
html.div(

docs/examples/python/use-query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from reactpy import component, html
2-
from reactpy_router import link, route, simple, use_search_params
2+
from reactpy_router import browser_router, link, route, use_search_params
33

44

55
@component
@@ -10,7 +10,7 @@ def search():
1010

1111
@component
1212
def root():
13-
return simple.router(
13+
return browser_router(
1414
route(
1515
"/",
1616
html.div(

docs/src/learn/routers-routes-and-links.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ We include built-in components that automatically handle routing, which enable S
44

55
## Routers and Routes
66

7-
The [`simple.router`][src.reactpy_router.simple.router] component is one possible implementation of a [Router][src.reactpy_router.types.Router]. Routers takes a series of [route][src.reactpy_router.route] objects as positional arguments and render whatever element matches the current location.
7+
The [`browser_router`][src.reactpy_router.browser_router] component is one possible implementation of a [Router][src.reactpy_router.types.Router]. Routers takes a series of [route][src.reactpy_router.route] objects as positional arguments and render whatever element matches the current location.
88

99
!!! abstract "Note"
1010

1111
The current location is determined based on the browser's current URL and can be found
1212
by checking the [`use_location`][reactpy.backend.hooks.use_location] hook.
1313

14-
Here's a basic example showing how to use `#!python simple.router` with two routes.
14+
Here's a basic example showing how to use `#!python browser_router` with two routes.
1515

1616
=== "components.py"
1717

@@ -21,9 +21,9 @@ Here's a basic example showing how to use `#!python simple.router` with two rout
2121

2222
Here we'll note some special syntax in the route path for the second route. The `#!python "*"` is a wildcard that will match any path. This is useful for creating a "404" page that will be shown when no other route matches.
2323

24-
### Simple Router
24+
### Browser Router
2525

26-
The syntax for declaring routes with the [simple.router][src.reactpy_router.simple.router] is very similar to the syntax used by [`starlette`](https://www.starlette.io/routing/) (a popular Python web framework). As such route parameters are declared using the following syntax:
26+
The syntax for declaring routes with the [`browser_router`][src.reactpy_router.browser_router] is very similar to the syntax used by [`starlette`](https://www.starlette.io/routing/) (a popular Python web framework). As such route parameters are declared using the following syntax:
2727

2828
```python linenums="0"
2929
/my/route/{param}

docs/src/learn/simple-application.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p class="intro" markdown>
22

3-
Here you'll learn the various features of `reactpy-router` and how to use them. These examples will utilize the [`reactpy_router.simple.router`][src.reactpy_router.simple.router].
3+
Here you'll learn the various features of `reactpy-router` and how to use them. These examples will utilize the [`reactpy_router.browser_router`][src.reactpy_router.browser_router].
44

55
</p>
66

docs/src/reference/router.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
::: src.reactpy_router.simple
1+
::: src.reactpy_router.browser_router

0 commit comments

Comments
 (0)