|
18 | 18 | from reactpy.core.types import VdomChild, VdomDict
|
19 | 19 | from reactpy.types import ComponentType, Context, Location
|
20 | 20 | from reactpy.web.module import export, module_from_file
|
| 21 | +from reactpy import html |
21 | 22 |
|
22 | 23 | from reactpy_router.types import Route, RouteCompiler, Router, RouteResolver
|
23 | 24 |
|
@@ -54,9 +55,12 @@ def router_component(
|
54 | 55 |
|
55 | 56 | if match is not None:
|
56 | 57 | element, params = match
|
57 |
| - return ConnectionContext( |
58 |
| - _route_state_context(element, value=_RouteState(set_location, params)), |
59 |
| - value=Connection(old_conn.scope, location, old_conn.carrier), |
| 58 | + return html._( |
| 59 | + ConnectionContext( |
| 60 | + _route_state_context(element, value=_RouteState(set_location, params)), |
| 61 | + value=Connection(old_conn.scope, location, old_conn.carrier), |
| 62 | + ), |
| 63 | + _history({"on_change": lambda event: set_location(Location(**event))}), |
60 | 64 | )
|
61 | 65 |
|
62 | 66 | return None
|
@@ -113,9 +117,9 @@ def _match_route(
|
113 | 117 | return None
|
114 | 118 |
|
115 | 119 |
|
116 |
| -_link = export( |
| 120 | +_link, _history = export( |
117 | 121 | module_from_file("reactpy-router", file=Path(__file__).parent / "bundle.js"),
|
118 |
| - "Link", |
| 122 | + ("Link", "History"), |
119 | 123 | )
|
120 | 124 |
|
121 | 125 |
|
|
0 commit comments