|
5 | 5 | from uuid import uuid4 |
6 | 6 |
|
7 | 7 | from reactpy import component, html, use_connection, use_ref |
8 | | -from reactpy.backend.types import Location |
9 | | -from reactpy.web.module import export, module_from_file |
| 8 | +from reactpy.types import Location |
| 9 | +from reactpy.reactjs import component_from_file |
10 | 10 |
|
11 | 11 | from reactpy_router.hooks import _use_route_state |
12 | 12 | from reactpy_router.types import Route |
13 | 13 |
|
14 | 14 | if TYPE_CHECKING: |
15 | | - from reactpy.core.component import Component |
16 | | - from reactpy.core.types import Key, VdomDict |
| 15 | + from reactpy.types import Key, VdomDict, Component |
17 | 16 |
|
18 | | -History = export( |
19 | | - module_from_file("reactpy-router", file=Path(__file__).parent / "static" / "bundle.js"), |
20 | | - ("History"), |
21 | | -) |
| 17 | +History = component_from_file(Path(__file__).parent / "static" / "bundle.js", import_names="History", name="reactpy-router") |
22 | 18 | """Client-side portion of history handling""" |
23 | 19 |
|
24 | | -Link = export( |
25 | | - module_from_file("reactpy-router", file=Path(__file__).parent / "static" / "bundle.js"), |
26 | | - ("Link"), |
27 | | -) |
| 20 | +Link = component_from_file(Path(__file__).parent / "static" / "bundle.js", import_names="Link", name="reactpy-router") |
28 | 21 | """Client-side portion of link handling""" |
29 | 22 |
|
30 | | -Navigate = export( |
31 | | - module_from_file("reactpy-router", file=Path(__file__).parent / "static" / "bundle.js"), |
32 | | - ("Navigate"), |
33 | | -) |
| 23 | +Navigate = component_from_file(Path(__file__).parent / "static" / "bundle.js", import_names="Navigate", name="reactpy-router") |
34 | 24 | """Client-side portion of the navigate component""" |
35 | 25 |
|
36 | 26 |
|
@@ -74,7 +64,7 @@ def _link(attributes: dict[str, Any], *children: Any) -> VdomDict: |
74 | 64 | def on_click_callback(_event: dict[str, Any]) -> None: |
75 | 65 | set_location(Location(**_event)) |
76 | 66 |
|
77 | | - return html._(Link({"onClickCallback": on_click_callback, "linkClass": class_name}), html.a(attrs, *children)) |
| 67 | + return html(Link({"onClickCallback": on_click_callback, "linkClass": class_name}), html.a(attrs, *children)) |
78 | 68 |
|
79 | 69 |
|
80 | 70 | def route(path: str, element: Any | None, *routes: Route) -> Route: |
@@ -118,7 +108,7 @@ def _navigate(to: str, replace: bool = False) -> VdomDict | None: |
118 | 108 | def on_navigate_callback(_event: dict[str, Any]) -> None: |
119 | 109 | set_location(Location(**_event)) |
120 | 110 |
|
121 | | - if location.pathname != pathname: |
| 111 | + if location.path != pathname: |
122 | 112 | return Navigate({"onNavigateCallback": on_navigate_callback, "to": to, "replace": replace}) |
123 | 113 |
|
124 | 114 | return None |
0 commit comments