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
@@ -44,6 +45,7 @@ def router_component(
44
45
) -> ComponentType | None :
45
46
old_conn = use_connection ()
46
47
location , set_location = use_state (old_conn .location )
48
+ print (location )
47
49
48
50
resolvers = use_memo (
49
51
lambda : tuple (map (compiler , _iter_routes (routes ))),
@@ -54,9 +56,12 @@ def router_component(
54
56
55
57
if match is not None :
56
58
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 ),
59
+ return html ._ (
60
+ ConnectionContext (
61
+ _route_state_context (element , value = _RouteState (set_location , params )),
62
+ value = Connection (old_conn .scope , location , old_conn .carrier ),
63
+ ),
64
+ _history ({"on_change" : lambda event : set_location (Location (** event ))}),
60
65
)
61
66
62
67
return None
@@ -113,9 +118,9 @@ def _match_route(
113
118
return None
114
119
115
120
116
- _link = export (
121
+ _link , _history = export (
117
122
module_from_file ("reactpy-router" , file = Path (__file__ ).parent / "bundle.js" ),
118
- "Link" ,
123
+ ( "Link" , "History" ) ,
119
124
)
120
125
121
126
0 commit comments