Skip to content

Commit ec1b633

Browse files
committed
use_params docstring
1 parent c86f37b commit ec1b633

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/reactpy_router/core.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@ def link(*children: VdomChild, to: str, **attributes: Any) -> VdomDict:
8484

8585

8686
def use_params() -> dict[str, Any]:
87-
"""Get parameters from the currently matching route pattern"""
87+
"""The `use_params` hook returns an object of key/value pairs of the dynamic params \
88+
from the current URL that were matched by the `Route`. Child routes inherit all params \
89+
from their parent routes.
90+
91+
For example, if you have a `URL_PARAM` defined in the route `/example/<URL_PARAM>/`,
92+
this hook will return the URL_PARAM value that was matched."""
93+
94+
# TODO: Check if this returns all parent params
8895
return _use_route_state().params
8996

9097

@@ -121,9 +128,7 @@ def _iter_routes(routes: Sequence[R]) -> Iterator[R]:
121128
yield parent
122129

123130

124-
def _match_route(
125-
compiled_routes: Sequence[RouteResolver], location: Location
126-
) -> tuple[Any, dict[str, Any]] | None:
131+
def _match_route(compiled_routes: Sequence[RouteResolver], location: Location) -> tuple[Any, dict[str, Any]] | None:
127132
for resolver in compiled_routes:
128133
match = resolver.resolve(location.pathname)
129134
if match is not None:

0 commit comments

Comments
 (0)