Skip to content

Commit d9a943a

Browse files
committed
Remove select from top level router
1 parent 7947e91 commit d9a943a

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/reactpy_router/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
create_router,
88
link,
99
route,
10-
router_component,
10+
router,
1111
use_params,
1212
use_search_params,
1313
)
@@ -19,10 +19,9 @@
1919
"create_router",
2020
"link",
2121
"route",
22-
"routers",
2322
"Route",
2423
"RouteCompiler",
25-
"router_component",
24+
"router",
2625
"RouteResolver",
2726
"browser_router",
2827
"use_params",

src/reactpy_router/core.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@ def route(path: str, element: Any | None, *routes: Route) -> Route:
3838
def create_router(compiler: RouteCompiler[R]) -> Router[R]:
3939
"""A decorator that turns a route compiler into a router"""
4040

41-
def wrapper(*routes: R, select: Literal["first", "all"] = "first") -> ComponentType:
42-
return router_component(*routes, select=select, compiler=compiler)
41+
def wrapper(*routes: R) -> ComponentType:
42+
return router(*routes, compiler=compiler)
4343

4444
return wrapper
4545

4646

4747
@component
48-
def router_component(
48+
def router(
4949
*routes: R,
50-
select: Literal["first", "all"],
5150
compiler: RouteCompiler[R],
5251
) -> VdomDict | None:
5352
"""A component that renders matching route(s) using the given compiler function."""
@@ -60,7 +59,7 @@ def router_component(
6059
dependencies=(compiler, hash(routes)),
6160
)
6261

63-
match = use_memo(lambda: _match_route(resolvers, location, select))
62+
match = use_memo(lambda: _match_route(resolvers, location, select="first"))
6463

6564
if match:
6665
route_elements = [
@@ -86,8 +85,8 @@ def link(*children: VdomChild, to: str, **attributes: Any) -> VdomDict:
8685
"""A component that renders a link to the given path.
8786
8887
FIXME: This currently works in a "dumb" way by trusting that ReactPy's script tag
89-
properly sets the location. When a client-server communication layer is added to
90-
ReactPy, this component will need to be rewritten to use that instead."""
88+
properly sets the location. When a client-server communication layer is added to a
89+
future ReactPy release, this component will need to be rewritten to use that instead."""
9190
set_location = _use_route_state().set_location
9291
uuid = uuid4().hex
9392

src/reactpy_router/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __hash__(self) -> int:
3838
class Router(Protocol[R_contra]):
3939
"""Return a component that renders the first matching route"""
4040

41-
def __call__(self, *routes: R_contra, select: Literal["first", "all"] = "first") -> ComponentType: ...
41+
def __call__(self, *routes: R_contra) -> ComponentType: ...
4242

4343

4444
class RouteCompiler(Protocol[R_contra]):

0 commit comments

Comments
 (0)